https://github.com/alxlu/suppress-chunks-webpack-plugin
plugin to suppress webpack chunks
https://github.com/alxlu/suppress-chunks-webpack-plugin
chunk suppress-webpack-chunks webpack
Last synced: 5 months ago
JSON representation
plugin to suppress webpack chunks
- Host: GitHub
- URL: https://github.com/alxlu/suppress-chunks-webpack-plugin
- Owner: alxlu
- License: mit
- Created: 2016-12-05T08:26:03.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2022-12-03T15:40:58.000Z (almost 3 years ago)
- Last Synced: 2024-09-17T03:53:18.084Z (about 1 year ago)
- Topics: chunk, suppress-webpack-chunks, webpack
- Language: JavaScript
- Size: 631 KB
- Stars: 6
- Watchers: 3
- Forks: 4
- Open Issues: 15
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# suppress chunks webpack plugin
[](https://travis-ci.org/alxlu/suppress-chunks-webpack-plugin)This plugin is intended to suppress webpack chunks.
## Install
`npm i -D suppress-chunks-webpack-plugin`## Usage
Here's how to suppress the chunks generated by the entry points `one` and `foo`
```js
var SuppressChunksPlugin = require('suppress-chunks-webpack-plugin');module.exports = {
...entry: {
one: './file.js',
foo: './foo.js',
bar: './bar.js',
main: './index.js',
},output: {
path: path.join(__dirname, '/dist')),
filename: '[name].js',
},plugins: [
...new SuppressChunksPlugin(['one', 'foo']);
]
}```
### Filtering out specific files
If you have a chunk that produces multiple output files e.g. if you're using something like `extract-text-webpack-plugin` to generate a `.css` file, you can filter out specific files in the chunk to suppress. Simply add an object instead of a string into the array: `{ name: string, match: regexp }`
```js
// one.js
require('./one.css');
```This would suppress `one.js`, but not `one.css`
```js
var SuppressChunksPlugin = require('suppress-chunks-webpack-plugin');module.exports = {
...
entry: {
one: './one.js',
foo: './foo.js',
bar: './bar.js',
main: './index.js',
},output: {
path: path.join(__dirname, '/dist')),
filename: '[name].js',
},
module: {
loaders: [{
...,
loader: ExtractTextPlugin.extract(
'style-loader',
'css-loader',
}],
},plugins: [
...
new ExtractTextPlugin('[name].css'),
new SuppressChunksPlugin([
{ name: 'one', match: /\.js$/ },
'foo',
'bar',
]);
]
```
### Filtering out specific patterns
If you want to filter out a pattern for all of your chunks, you can pass in an options object as the second parameter:
```js
new SuppressChunksPlugin([
'one',
'two',
'foo',
'bar',
{ name: 'file', match: /\.css$/ },
// entries passed in with a match field have priority over the options object.
], { filter: /\.js$/ });
```