https://github.com/fabiandev/split-by-path-webpack-plugin
https://github.com/fabiandev/split-by-path-webpack-plugin
javascript webpack webpack-plugin
Last synced: 8 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/fabiandev/split-by-path-webpack-plugin
- Owner: fabiandev
- License: other
- Created: 2016-06-14T21:30:13.000Z (about 10 years ago)
- Default Branch: master
- Last Pushed: 2017-01-20T13:34:41.000Z (over 9 years ago)
- Last Synced: 2024-08-10T21:28:40.719Z (almost 2 years ago)
- Topics: javascript, webpack, webpack-plugin
- Language: JavaScript
- Size: 6.84 KB
- Stars: 4
- Watchers: 3
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
## Split By Path Webpack Plugin
This plugin will split your entry bundle into any number of arbitrarily defined smaller bundles.
> Note: For webpack v1.x use version 0.x of this package, 1.x for webpack v2.x
## Credits
This plugin is based on [split-by-name-webpack-plugin](https://github.com/soundcloud/split-by-name-webpack-plugin).
### How?
Configuration of the plugin is simple. You instantiate the plugin with a single option: `buckets` which should be an
array of objects, each containing the keys `name` and `regex`. Any modules which are in your entry chunk which match the
bucket's regex (first matching bucket is used), are then moved to a new chunk with the given name.
Creating a 'catch-all' bucket is not necessary: anything which doesn't match one of the defined buckets will be left in
the original chunk.
### Example
```js
var SplitByPathPlugin = require('split-by-path-webpack-plugin');
module.exports = {
entry: {
app: 'app.js'
},
output: {
path: __dirname + '/dist',
filename: "[name]-[chunkhash].js",
chunkFilename: "[name]-[chunkhash].js"
},
plugins: [
new SplitByPathPlugin({
buckets: [{
name: 'vendor',
regex: /(node_modules\/|src\/vendor\/)/
}]
})
]
};
```