|
|
|
const path = require('path');
|
|
|
|
// const CopyWebpackPlugin = require('copy-webpack-plugin'); // 最新版本copy-webpack-plugin插件暂不兼容,推荐v5.0.0
|
|
|
|
const CompressionWebpackPlugin = require('compression-webpack-plugin');
|
|
|
|
const productionGzipExtensions = /\.(js|css|json|txt|html|ico|svg|ttf|woff|woff2)(\?.*)?$/i;
|
|
|
|
const isPro = process.env.NODE_ENV === 'production';
|
|
|
|
|
|
|
|
module.exports = {
|
|
|
|
lintOnSave: process.env.NODE_ENV !== 'production',
|
|
|
|
productionSourceMap: false,
|
|
|
|
devServer: {
|
|
|
|
// open: true,
|
|
|
|
// host: '127.0.0.1',
|
|
|
|
overlay: { warnings: false, errors: true },
|
|
|
|
// proxy: {}
|
|
|
|
},
|
|
|
|
configureWebpack: {
|
|
|
|
plugins: isPro
|
|
|
|
? [
|
|
|
|
new CompressionWebpackPlugin({
|
|
|
|
filename: '[path].gz[query]',
|
|
|
|
algorithm: 'gzip',
|
|
|
|
test: productionGzipExtensions,
|
|
|
|
threshold: 10240,
|
|
|
|
minRatio: 0.8,
|
|
|
|
deleteOriginalAssets: false,
|
|
|
|
}),
|
|
|
|
]
|
|
|
|
: [],
|
|
|
|
},
|
|
|
|
pluginOptions: {
|
|
|
|
// mock: { entry: './src/mock/mock.js', debug: true, disable: true },
|
|
|
|
eruda: {},
|
|
|
|
webpackBundleAnalyzer: {
|
|
|
|
openAnalyzer: isPro,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
};
|