Skip to content

Commit

Permalink
Add optimize option, use in web, node. (neutrinojs#460)
Browse files Browse the repository at this point in the history
  • Loading branch information
timkelty authored and eliperelman committed Nov 21, 2017
1 parent 076f6d4 commit c57de40
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 2 deletions.
2 changes: 2 additions & 0 deletions packages/neutrino/src/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ const getOptions = (opts = {}) => {
.keys(options.env)
.forEach(env => process.env[env] = options.env[env]);

options.optimize = defaultTo(options.env.NODE_ENV === 'production', options.optimize);

pathOptions.forEach(([path, defaultValue, getNormalizeBase]) => {
let value = defaultTo(defaultValue, options[path]);

Expand Down
2 changes: 1 addition & 1 deletion packages/node/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ module.exports = (neutrino, opts = {}) => {
config.devtool('inline-sourcemap');
config.output.devtoolModuleFilenameTemplate('[absolute-resource-path]');
})
.when(neutrino.options.env.NODE_ENV === 'production', (config) => {
.when(neutrino.options.optimize, (config) => {
config.plugin('module-concat').use(optimize.ModuleConcatenationPlugin);
})
.when(neutrino.options.command === 'build', () => {
Expand Down
2 changes: 1 addition & 1 deletion packages/web/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ module.exports = (neutrino, opts = {}) => {
neutrino.use(devServer, options.devServer);
config.when(options.hot, () => neutrino.use(hot));
})
.when(process.env.NODE_ENV === 'production', () => {
.when(neutrino.options.optimize, () => {
neutrino.use(chunk);
neutrino.use(minify);
neutrino.config.plugin('module-concat')
Expand Down

0 comments on commit c57de40

Please sign in to comment.