|
|
@ -42,8 +42,6 @@ function devServer({ config }, options) { |
|
|
|
} |
|
|
|
|
|
|
|
module.exports = (neutrino) => { |
|
|
|
const { config } = neutrino; |
|
|
|
|
|
|
|
if (!path(['options', 'compile', 'targets', 'browsers'], neutrino)) { |
|
|
|
Object.assign(neutrino.options, { |
|
|
|
compile: { |
|
|
@ -83,28 +81,38 @@ module.exports = (neutrino) => { |
|
|
|
} |
|
|
|
}); |
|
|
|
|
|
|
|
if (process.env.NODE_ENV !== 'test') { |
|
|
|
neutrino.use(chunk); |
|
|
|
} |
|
|
|
|
|
|
|
config |
|
|
|
neutrino.config |
|
|
|
.when(process.env.NODE_ENV !== 'test', () => neutrino.use(chunk)) |
|
|
|
.target('web') |
|
|
|
.context(neutrino.options.root) |
|
|
|
.entry('index') |
|
|
|
.add(require.resolve('babel-polyfill')) |
|
|
|
.add(neutrino.options.entry); |
|
|
|
|
|
|
|
config.output |
|
|
|
.add(neutrino.options.entry) |
|
|
|
.end() |
|
|
|
.output |
|
|
|
.path(neutrino.options.output) |
|
|
|
.publicPath('./') |
|
|
|
.filename('[name].bundle.js') |
|
|
|
.chunkFilename('[id].[chunkhash].js'); |
|
|
|
|
|
|
|
config.resolve.modules.add('node_modules').add(neutrino.options.node_modules).add(MODULES); |
|
|
|
config.resolve.extensions.add('.js').add('.json'); |
|
|
|
config.resolveLoader.modules.add(neutrino.options.node_modules).add(MODULES); |
|
|
|
|
|
|
|
config.node |
|
|
|
.chunkFilename('[id].[chunkhash].js') |
|
|
|
.end() |
|
|
|
.resolve |
|
|
|
.modules |
|
|
|
.add('node_modules') |
|
|
|
.add(neutrino.options.node_modules) |
|
|
|
.add(MODULES) |
|
|
|
.end() |
|
|
|
.extensions |
|
|
|
.add('.js') |
|
|
|
.add('.json') |
|
|
|
.end() |
|
|
|
.end() |
|
|
|
.resolveLoader |
|
|
|
.modules |
|
|
|
.add(neutrino.options.node_modules) |
|
|
|
.add(MODULES) |
|
|
|
.end() |
|
|
|
.end() |
|
|
|
.node |
|
|
|
.set('console', false) |
|
|
|
.set('global', true) |
|
|
|
.set('process', true) |
|
|
@ -113,16 +121,14 @@ module.exports = (neutrino) => { |
|
|
|
.set('__dirname', 'mock') |
|
|
|
.set('setImmediate', true) |
|
|
|
.set('fs', 'empty') |
|
|
|
.set('tls', 'empty'); |
|
|
|
|
|
|
|
if (config.module.rules.has('lint')) { |
|
|
|
neutrino.use(loaderMerge('lint', 'eslint'), { |
|
|
|
.set('tls', 'empty') |
|
|
|
.end() |
|
|
|
.when(neutrino.config.module.rules.has('lint'), () => neutrino |
|
|
|
.use(loaderMerge('lint', 'eslint'), { |
|
|
|
globals: ['Buffer'], |
|
|
|
envs: ['browser', 'commonjs'] |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
if (process.env.NODE_ENV === 'development') { |
|
|
|
})) |
|
|
|
.when(process.env.NODE_ENV === 'development', (config) => { |
|
|
|
const protocol = process.env.HTTPS ? 'https' : 'http'; |
|
|
|
const host = process.env.HOST || pathOr('localhost', ['options', 'config', 'devServer', 'host'], neutrino); |
|
|
|
const port = process.env.PORT || pathOr(5000, ['options', 'config', 'devServer', 'port'], neutrino); |
|
|
@ -140,7 +146,7 @@ module.exports = (neutrino) => { |
|
|
|
.entry('index') |
|
|
|
.add(`webpack-dev-server/client?${protocol}://${host}:${port}/`) |
|
|
|
.add('webpack/hot/dev-server'); |
|
|
|
} else { |
|
|
|
}, (config) => { |
|
|
|
neutrino.use(clean, { paths: [neutrino.options.output] }); |
|
|
|
neutrino.use(minify); |
|
|
|
neutrino.use(copy, { |
|
|
@ -148,5 +154,5 @@ module.exports = (neutrino) => { |
|
|
|
options: { ignore: ['*.js*'] } |
|
|
|
}); |
|
|
|
config.output.filename('[name].[chunkhash].bundle.js'); |
|
|
|
} |
|
|
|
}); |
|
|
|
}; |
|
|
|