Authored by 毕凯

webpack 4

... ... @@ -125,7 +125,7 @@
"postcss-short": "^4.1.0",
"postcss-sprites": "^4.2.1",
"postcss-use": "^3.0.0",
"precss": "^3.1.2",
"precss": "^1.4.0",
"shelljs": "^0.8.1",
"store": "^2.0.12",
"style-loader": "^0.21.0",
... ... @@ -138,6 +138,7 @@
"vue-loader": "^14.2.2",
"vue-template-compiler": "^2.5.16",
"webpack": "^4.6.0",
"webpack-cli": "^2.0.15",
"webpack-dev-middleware": "^3.1.2",
"webpack-dev-server": "^3.1.3",
"webpack-hot-middleware": "^2.22.1",
... ...
... ... @@ -105,17 +105,28 @@ module.exports = (env) => {
stats: {
children: false
},
optimization: {
splitChunks: {
cacheGroups: {
default: false,
libs: {
test: (file) => {
if (file.rawRequest === 'yoho-jquery') {
return true;
}
// optimization: {
// splitChunks: {
// cacheGroups: {
// libs: {
// name: 'libs',
// chunks: 'initial'
// }
// }
// }
// },
if (file.rawRequest === path.join(__dirname, '../js/global.js')) {
return true;
}
return false;
},
name: 'libs',
chunks: 'all'
}
}
}
},
performance: {
maxEntrypointSize: 5120000,
maxAssetSize: 5120000
... ...
const webpack = require('webpack');
const path = require('path');
const shelljs = require('shelljs');
const {cssLoader} = require('./utils.js');
... ... @@ -12,6 +11,7 @@ shelljs.cp('-R', path.join(__dirname, '../img/'), distDir);
shelljs.cp('-R', path.join(__dirname, '../font/'), distDir);
let webpackConfig = {
mode: 'production',
entry: {
index: [path.join(__dirname, '../scss/index.css')]
},
... ... @@ -25,13 +25,15 @@ let webpackConfig = {
use: cssLoader('pro', 'css')
}]
},
stats: {
children: false
},
performance: {
maxEntrypointSize: 5120000,
maxAssetSize: 5120000
},
plugins: [
new ExtractTextPlugin('[name].css'),
new webpack.DefinePlugin({
'process.env': {
NODE_ENV: '"production"'
}
})
new ExtractTextPlugin('[name].css')
]
};
... ...