package
This plugin splits minification of webpack compilations into smaller units.
npm install @rushstack/webpack5-module-minifier-pluginGitHub-flavored package documentation.
Across all versions.
Download trend unavailable.
Runtime metadata.
Estimated unpacked size across 5 packages.
703.6 kB
Includes dependencies.
4 direct · 3 outdated
2.2.1
2.3.4
1.0.8
1.0.10
1.0.6
2.3.0
0.7.32
0.7.32
This package contains a plugin for webpack 5 that performs minification on a per-module basis rather than per-asset to deduplicate and parallelize compression work.
npm install @rushstack/webpack5-module-minifier-plugin --save-dev
This Webpack plugin performs minification of production assets on a per-module basis, rather than minifying an entire chunk at a time. It issues async calls to the minifier for each unique module and each unique set of chunk boilerplate (i.e. the webpack runtime and the structure of the module list). Separately emitted runtime chunks are minified even when they contain no ordinary JavaScript modules. This improves minification time by:
[hash] and [contenthash] tokensThe plugin will do its best to update webpack hashes if changing the direct inputs (useSourceMap) to the plugin, but if altering the minifier property itself, you may need to use the output.hashSalt property to force a change to the hashes, especially if leveraging the MessagePortMinifier or similar, since it has no direct access to the configuration of the minifier.
const { ModuleMinifierPlugin } = require('@rushstack/webpack5-module-minifier-plugin');
const { WorkerPoolMinifier } = require('@rushstack/module-minifier');
// In your webpack options:
optimization: {
minimizer: [
new ModuleMinifierPlugin({
minifier: new WorkerPoolMinifier(),
// If not provided, the plugin will attempt to guess from `mode` and `devtool`.
// Providing it expressly gives better results
useSourceMap: true
})
]
}You can also run the ModuleMinifierPlugin in a single-threaded configuration.
// webpack.config.js
const { ModuleMinifierPlugin } = require('@rushstack/webpack5-module-minifier-plugin');
const { LocalMinifier } = require('@rushstack/module-minifier');
// In your webpack options:
optimization: {
minimizer: [
new ModuleMinifierPlugin({
minifier: new LocalMinifier()
})
]
}By default, the plugin extracts license comments into a companion .LICENSE.txt
asset and adds a reference banner to the JavaScript chunk.
Set inlineShortLicenses: true in the ModuleMinifierPlugin options to inline
the complete license text when it is smaller than that banner. The comparison
uses UTF-8 byte lengths after deduplicating all license comments in the chunk.
Equal-size and larger notices remain in companion assets.
new ModuleMinifierPlugin({
minifier: new LocalMinifier(),
inlineShortLicenses: true
});The decision is made before emitting the companion asset. Inlined comments participate in source-map generation, module-position metadata, and content hashes.
@rushstack/webpack5-module-minifier-plugin is part of the Rush Stack family of projects.
odspnpm
odspnpm@microsoft.com