Authored by 毕凯

webpack4 配置

... ... @@ -104,7 +104,7 @@
"extract-text-webpack-plugin": "^4.0.0-beta.0",
"friendly-errors-webpack-plugin": "^1.7.0",
"handlebars-loader": "^1.7.0",
"happypack": "^4.0.1",
"happypack": "^5.0.0-beta.3",
"husky": "^0.14.3",
"intersection-observer": "^0.5.0",
"jquery-lazyload": "^1.9.7",
... ...
... ... @@ -105,6 +105,21 @@ module.exports = (env) => {
stats: {
children: false
},
// optimization: {
// splitChunks: {
// cacheGroups: {
// libs: {
// name: 'libs',
// chunks: 'initial'
// }
// }
// }
// },
performance: {
maxEntrypointSize: 5120000,
maxAssetSize: 5120000
},
plugins: [
new HappyPack({
id: 'js',
... ... @@ -116,10 +131,11 @@ module.exports = (env) => {
threadPool: happyThreadPool,
loaders: [hbsLoader]
}),
new webpack.optimize.CommonsChunkPlugin({
name: 'libs',
filename: 'libs.js'
}),
// new webpack.optimize.CommonsChunkPlugin({
// name: 'libs',
// filename: 'libs.js'
// }),
new webpack.ProvidePlugin({
$: 'yoho-jquery',
jQuery: 'yoho-jquery',
... ...
... ... @@ -17,10 +17,15 @@ if (devInfo.publicPath.indexOf('https')) {
}
module.exports = merge(baseConfig, {
mode: 'development',
output: {
publicPath: devInfo.publicPath
},
devtool: 'source-map',
performance: {
maxEntrypointSize: 20480000,
maxAssetSize: 20480000
},
plugins: [
new ExtractTextPlugin('[name].css'),
new webpack.HotModuleReplacementPlugin(),
... ...
... ... @@ -2,7 +2,6 @@
const path = require('path');
const shelljs = require('shelljs');
const webpack = require('webpack');
const merge = require('webpack-merge');
const ExtractTextPlugin = require('extract-text-webpack-plugin');
const config = require('../../package.json');
... ... @@ -18,25 +17,11 @@ shelljs.cp('-R', path.join(__dirname, './dll/*'), distDir);
baseConfig = baseConfig('pro');
module.exports = merge(baseConfig, {
mode: 'production',
output: {
path: distDir
},
plugins: [
new ExtractTextPlugin('[name].css'),
new webpack.DefinePlugin({
'process.env': {
NODE_ENV: '"production"'
}
}),
new webpack.optimize.UglifyJsPlugin({
parallel: true,
sourceMap: true,
uglifyOptions: {
compress: {
warnings: false
},
comments: false
}
})
new ExtractTextPlugin('[name].css')
]
});
... ...