Skip to content
This repository has been archived by the owner on Dec 6, 2021. It is now read-only.

Commit

Permalink
split node_modules by default
Browse files Browse the repository at this point in the history
  • Loading branch information
egoist committed Feb 14, 2017
1 parent c3ff9a7 commit 08d6100
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
9 changes: 1 addition & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -184,14 +184,7 @@ module.exports = {

### Code splitting

To split vendor code and app code, you can set vendor dependencies using `vendor` option:

```js

module.exports = {
vendor: ['vue']
}
```
We enabled code splitting for vendor code and app code by default in production mode, you can set `vendor` option to `false` to disable it. And by default all required modules in `node_modules` will be splitted.

[⬆ back to top](#vbuild)

Expand Down
15 changes: 11 additions & 4 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,9 @@ function start(cliOptions) { // eslint-disable-line complexity
hmrEntry: ['client']
}, options)
} else {
options = Object.assign({}, options)
options = Object.assign({
vendor: true
}, options)
}

const filename = getFilenames(options)
Expand Down Expand Up @@ -228,11 +230,16 @@ function start(cliOptions) { // eslint-disable-line complexity
})
)

if (options.vendor) {
webpackConfig.entry.vendor = options.vendor
if (options.vendor !== false) {
webpackConfig.plugins.push(
new webpack.optimize.CommonsChunkPlugin({
names: ['vendor', 'manifest']
name: 'vendor',
minChunks: module => {
return module.resource && /\.js$/.test(module.resource) && module.resource.indexOf('node_modules') !== -1
}
}),
new webpack.optimize.CommonsChunkPlugin({
name: 'manifest'
})
)
}
Expand Down

0 comments on commit 08d6100

Please sign in to comment.