diff --git a/packages/neutrino/src/api.js b/packages/neutrino/src/api.js index 24edfb327..c51f59603 100644 --- a/packages/neutrino/src/api.js +++ b/packages/neutrino/src/api.js @@ -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]); diff --git a/packages/node/index.js b/packages/node/index.js index 686e06d32..acbab24b4 100644 --- a/packages/node/index.js +++ b/packages/node/index.js @@ -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', () => { diff --git a/packages/web/index.js b/packages/web/index.js index a7a20e476..51dd3dbe3 100644 --- a/packages/web/index.js +++ b/packages/web/index.js @@ -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')