@nsmp/asset-size-webpack-plugin
v1.0.0
Published
Webpack plugin to control assets size
Downloads
1
Readme
AssetSizeWebpackPlugin
Webpack plugin for controlling build file sizes.
How it works
The plugin interrupts the build and outputs errors with information about build files that exceed the specified limits to the console. The check starts and ends with log messages in the console.
Installation
npm install --save-dev @nsmp/asset-size-webpack-plugin
Configuration
The settings object includes two optional parameters: assetSize
and defaultAssetSize
assetSize
An object that sets the maximum size in bytes for specific build files by mask. For example:
assetSize: {
// all files containing "summerNote" in its name will be checked
summerNote: 20000,
// file summerNote.js will be checked
'summerNote.js': 10000
}
defaultAssetSize
Sets the default maximum size in bytes that is applied to all build files that do not match any masks specified in the assetSize
parameter.
For example:
defaultAssetSize: 5000
Usage
Add the plugin to your webpack config:
const AssetSizeWebpackPlugin = require('@nsmp/asset-size-webpack-plugin');
module.exports = {
// ...
plugins: [
new AssetSizeWebpackPlugin({
assetSize: {
summerNote: 20000,
'summerNote.js': 10000
},
defaultAssetSize: 5000
})
]
};