|
@@ -83,24 +83,43 @@ module.exports = {
|
|
chainWebpack: config => {
|
|
chainWebpack: config => {
|
|
// single-spa
|
|
// single-spa
|
|
if (!process.env.VUE_APP_ALONE) {
|
|
if (!process.env.VUE_APP_ALONE) {
|
|
- config.devServer.set('inline', false)
|
|
|
|
- config.devServer.set('hot', true)
|
|
|
|
|
|
|
|
if (process.env.NODE_ENV === 'production') {
|
|
if (process.env.NODE_ENV === 'production') {
|
|
- config.externals([
|
|
|
|
- 'vue',
|
|
|
|
- 'vue-router',
|
|
|
|
- 'vuex',
|
|
|
|
- 'axios',
|
|
|
|
- 'lodash',
|
|
|
|
- 'moment'
|
|
|
|
- ])
|
|
|
|
- config.plugin('html').tap(args => {
|
|
|
|
- // html中添加cdn
|
|
|
|
- args[0].cdn = cdn
|
|
|
|
- return args
|
|
|
|
- })
|
|
|
|
|
|
+ // 生产环境配置
|
|
|
|
+ config.externals([
|
|
|
|
+ 'vue',
|
|
|
|
+ 'vue-router',
|
|
|
|
+ 'vuex',
|
|
|
|
+ 'axios',
|
|
|
|
+ 'lodash',
|
|
|
|
+ 'moment'
|
|
|
|
+ ])
|
|
|
|
+ config.plugin('html').tap(args => {
|
|
|
|
+ // html中添加cdn
|
|
|
|
+ args[0].cdn = cdn
|
|
|
|
+ return args
|
|
|
|
+ })
|
|
|
|
+ // config.output.filename('./js/[name].[chunkhash:8].js')
|
|
|
|
+ config.output.filename = function (pathData) {
|
|
|
|
+ return pathData.chunk.name === 'app' ? './js/[name].js' : './js/[name].[chunkhash:8].js';
|
|
|
|
+ };
|
|
|
|
+ config.output.chunkFilename('./js/[name].[chunkhash:8].js');
|
|
|
|
+ // config.output.chunkFilename = function (pathData) {
|
|
|
|
+ // console.log(JSON.stringify(pathData.chunk), '11')
|
|
|
|
+ // return pathData.chunk.name === 'app' ? './js/[name].js' : './js/[name].[chunkhash:8].js';
|
|
|
|
+ // };
|
|
|
|
+
|
|
|
|
+ config.optimization.minimize(true)
|
|
|
|
+ .minimizer('terser')
|
|
|
|
+ .tap(args => {
|
|
|
|
+ let { terserOptions } = args[0];
|
|
|
|
+ terserOptions.compress.drop_console = true;
|
|
|
|
+ terserOptions.compress.drop_debugger = true;
|
|
|
|
+ return args
|
|
|
|
+ });
|
|
} else {
|
|
} else {
|
|
|
|
+ config.devServer.set('inline', false)
|
|
|
|
+ config.devServer.set('hot', true)
|
|
config.output.filename('js/[name].js')
|
|
config.output.filename('js/[name].js')
|
|
}
|
|
}
|
|
}
|
|
}
|