Skip to content

Commit

Permalink
feat: code splitting and default vendor chunk
Browse files Browse the repository at this point in the history
  • Loading branch information
Guillaume Chau committed Nov 13, 2018
1 parent e3375eb commit 99dba92
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
2 changes: 1 addition & 1 deletion packages/@moonreach/nodepack/src/config/base.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ module.exports = (api, options) => {
// Output
config.output
.set('path', api.resolve(options.outputDir))
.set('filename', 'app.js')
.set('filename', '[name].js')
.set('libraryTarget', 'commonjs2')

// Resolve
Expand Down
14 changes: 14 additions & 0 deletions packages/@moonreach/nodepack/src/config/prod.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,20 @@ module.exports = (api, options) => {
.minimizer('terser')
.use(TerserPlugin, [terserOptions(options)])
}

if (options.externals === false) {
config
.optimization.splitChunks({
cacheGroups: {
vendors: {
name: `vendors`,
test: /[\\/]node_modules[\\/]/,
priority: -10,
chunks: 'initial',
},
},
})
}
}
})
}

0 comments on commit 99dba92

Please sign in to comment.