Skip to content
This repository has been archived by the owner on Feb 18, 2024. It is now read-only.

Add optimize option, use in web, node. #460

Merged
merged 1 commit into from Nov 21, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions packages/neutrino/src/api.js
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
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
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