Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
This repository was archived by the owner on Aug 8, 2019. It is now read-only.
/docsPublic archive

internal webpack plugins

Lewis Barclay edited this pageNov 2, 2018 ·16 revisions

This is a list of plugins, which are internally used by webpack. You should only care about them if you are building a own compiler based on webpack, or introspect the internals.

categories of internal plugins:

  • environment
  • compiler
  • entry
  • output
  • source
  • optimize

environment

Plugins affecting the environment of the compiler.

node/NodeEnvironmentPlugin

Applies node.js style filesystem to the compiler.

compiler

Plugins affecting the compiler

CachePlugin([cache])

Adds a cache to the compiler, where modules are cached.

You can pass acache object, where the modules are cached. Otherwise one is created per plugin instance.

ProgressPlugin(handler)

Hook into the compiler to extract progress information. Thehandler must have the signaturefunction(percentage, message). It's called with0 <= percentage <= 1.percentage == 0 indicates the start.percentage == 1 indicates the end.

RecordIdsPlugin()

Saves and restores module and chunk ids from records.

entry

Plugins, which add entry chunks to the compilation.

SingleEntryPlugin(context, request, chunkName)

Adds a entry chunk on compilation. The chunk is namedchunkName and contains only one module (plus dependencies). The module is resolved fromrequest incontext (absolute path).

MultiEntryPlugin(context, requests, chunkName)

Adds a entry chunk on compilation. The chunk is namedchunkName and contains a module for each item in therequests array (plus dependencies). Each item inrequests is resolved incontext (absolute path).

PrefetchPlugin(context, request)

Prefetchesrequest and dependencies to enables more parallel compilation. It doesn't create any chunk. The module is resolved fromrequest incontext (absolute path).

output

FunctionModulePlugin(context, options)

Each emitted module is wrapped in a function.

options are the output options.

Ifoptions.pathinfo is set, each module function is annotated with a comment containing the module identifier shortened tocontext (absolute path).

JsonpTemplatePlugin(options)

Chunks are wrapped into JSONP-calls. A loading algorithm is included in entry chunks. It loads chunks by adding a<script> tag.

options are the output options.

options.jsonpFunction is the JSONP function.

options.publicPath is uses as path for loading the chunks.

options.chunkFilename is the filename under that chunks are expected.

node/NodeTemplatePlugin(options)

Chunks are wrapped into node.js modules exporting the bundled modules. The entry chunks loads chunks by requiring them.

options are the output options.

options.chunkFilename is the filename under that chunks are expected.

LibraryTemplatePlugin(name, target)

The entries chunks are decorated to form a libraryname of typetype.

webworker/WebWorkerTemplatePlugin(options)

Chunks are loaded byimportScripts. Else it's similar toJsonpTemplatePlugin.

options are the output options.

EvalDevToolModulePlugin

Decorates the module template by wrapping each module in aeval annotated with// @sourceURL.

SourceMapDevToolPlugin(sourceMapFilename, sourceMappingURLComment, moduleFilenameTemplate, fallbackModuleFilenameTemplate)

Decorates the templates by generating a SourceMap for each chunk.

sourceMapFilename the filename template of the SourceMap.[hash],[name],[id],[file] and[filebase] are replaced. If this argument is missing, the SourceMap will be inlined as DataUrl.

NoHotModuleReplacementPlugin()

Definesmodule.hot asfalse to remove hot module replacement code.

HotModuleReplacementPlugin(options)

Add support for hot module replacement. Decorates the templates to add runtime code. Addsmodule.hot API.

options.hotUpdateChunkFilename The filename for hot update chunks

options.hotUpdateMainFilename The filename for the hot update manifest

options.hotUpdateFunction JSON function name for the hot update

source

Plugins affecting the source code of modules.

APIPlugin

Make__webpack_public_path__,__webpack_require__,__webpack_modules__,__webpack_chunk_load__ accessible. Ensures thatrequire.valueOf andrequire.onError are not processed by other plugins.

CompatibilityPlugin

Currently useless. Ensures compatibility with other module loaders.

ConsolePlugin

Offers a pseudoconsole if it is not available.

ConstPlugin

Try to evaluate expressions inif(...) and replace it withtrue/false.

ProvidePlugin(name, request)

Ifname is used in a module it is filled by a module loaded byrequire(<request>).

NodeStuffPlugin(options, context)

Provide stuff that is normally available in node.js modules.

It also ensures thatmodule is filled with some node.js stuff if you use it.

RequireJsStuffPlugin

Provide stuff that is normally available in require.js.

require[js].config is removed.require.version is0.0.0.requirejs.onError is mapped torequire.onError.

node/NodeSourcePlugin(options)

This module adds stuff from node.js that is not available in non-node.js environments.

It adds polyfills forprocess,console,Buffer andglobal if used. It also binds the built in Node.js replacement modules.

node/NodeTargetPlugin

The plugins should be used if you run the bundle in a node.js environment.

If ensures that native modules are loaded correctly even if bundled.

dependencies/AMDPlugin(options)

Provides AMD-styledefine andrequire to modules. Also bindrequire.amd,define.amd and__webpack_amd_options__ to theoptions passed as parameter.

dependencies/CommonJsPlugin

Provides CommonJs-stylerequire to modules.

dependencies/LabeledModulesPlugin

Provide labelsrequire: andexports: to modules.

dependencies/RequireContextPlugin(modulesDirectories, extensions)

Providesrequire.context. The parametermodulesDirectories andextensions are used to find alternative requests for files. It's useful to provide the same arrays as you provide to the resolver.

dependencies/RequireEnsurePlugin

Providesrequire.ensure.

dependencies/RequireIncludePlugin

Providesrequire.include.

DefinePlugin(definitions)

Define constants for identifier.

definitions is an object.

optimize

optimize/LimitChunkCountPlugin(options)

Merge chunks limit chunk count is lower thanoptions.maxChunks.

The overhead for each chunks is provided byoptions.chunkOverhead or defaults to 10000. Entry chunks sizes are multiplied byoptions.entryChunkMultiplicator (or 10).

Chunks that reduce the total size the most are merged first. If multiple combinations are equal the minimal merged size wins.

optimize/MergeDuplicateChunksPlugin

Chunks with the same modules are merged.

optimize/RemoveEmptyChunksPlugin

Modules that are included in every parent chunk are removed from the chunk.

optimize/MinChunkSizePlugin(minChunkSize)

Merges chunks until each chunk has the minimum size ofminChunkSize.

optimize/FlagIncludedChunksPlugin

Adds chunk ids of chunks which are included in the chunk. This eliminates unnecessary chunk loads.

optimize/UglifyJsPlugin(options)

Minimizes the chunks withuglify.js.

options are uglifyjs options.

optimize/OccurenceOrderPlugin(preferEntry)

Order the modules and chunks by occurrence. This saves space, because often referenced modules and chunks get smaller ids.

preferEntry If true, references in entry chunks have higher priority

optimize/DedupePlugin

Deduplicates modules and adds runtime code.

webpack 👍

Clone this wiki locally


[8]ページ先頭

©2009-2025 Movatter.jp