const path = require('path')module.exports = { publicPath: process.env.NODE_ENV === 'production' ? '/isight/' : '/', productionSourceMap: false, // 生产环境不需要source map pluginOptions: { // vue add style-resources-loader添加插件 'style-resources-loader': { preProcessor: 'scss', patterns: [path.resolve(__dirname, 'src/assets/styles/variables.scss')] }, // vue add lodash添加插件 lodash: { // 是否开启ProvidePlugin, 默认false provide: true } }, chainWebpack: config => { // 移除 preload 插件 config.plugins.delete('preload') // 移除 prefetch 插件 config.plugins.delete('prefetch') }, configureWebpack: config => { // 打包优化参考:https://blog.csdn.net/weixin_43638968/article/details/109093199 config.optimization = { runtimeChunk: 'single', splitChunks: { chunks: 'all', maxInitialRequests: Infinity, minSize: 1000 * 60, cacheGroups: { vendor: { test: /[\\/]node_modules[\\/]/, name (module) { // 排除node_modules 然后吧 @ 替换为空 ,考虑到服务器的兼容 const packageName = module.context.match( /[\\/]node_modules[\\/](.*?)([\\/]|$)/ )[1] return `${packageName.replace('@', '')}` } } } } } }}