This commit is contained in:
2025-07-17 16:40:38 +08:00

View File

@@ -18,9 +18,9 @@ module.exports = {
'/api': {
target: 'http://127.0.0.1:7100',
changeOrigin: true,
rewrite: path => path.replace(/^\/api/, '')
}
}
rewrite: (path) => path.replace(/^\/api/, ''),
},
},
},
css: {
sourceMap: true, // 查看css属于哪个css文件
@@ -32,22 +32,19 @@ module.exports = {
viewportWidth: 375,
// 该项仅在使用 Circle 组件时需要
// 原因参见 https://github.com/youzan/vant/issues/1948
selectorBlackList: ['van-circle__layer']
})
]
}
}
selectorBlackList: ['van-circle__layer'],
}),
],
},
},
},
chainWebpack: config => {
chainWebpack: (config) => {
// 移除 prefetch 插件
config.resolve.alias.set('@utils', resolve('./src/assets/js/utils'))
// config.plugins.delete('prefetch')
/* 配置svg图标自动加载 begin */
config.module
.rule('svg')
.exclude.add(resolve('src/icons'))
.end()
config.module.rule('svg').exclude.add(resolve('src/icons')).end()
config.module
.rule('icons')
.test(/\.svg$/)
@@ -56,16 +53,16 @@ module.exports = {
.use('svg-sprite-loader')
.loader('svg-sprite-loader')
.options({
symbolId: 'icon-[name]'
symbolId: 'icon-[name]',
})
config.plugin('code-inspector-plugin').use(
codeInspectorPlugin({
bundler: 'webpack'
bundler: 'webpack',
})
)
},
configureWebpack: config => {
configureWebpack: (config) => {
;(config.devtool = 'source-map'), // 调试js
(config.performance = {
hints: 'error',
@@ -73,10 +70,6 @@ module.exports = {
maxEntrypointSize: 7168000,
//生成文件的最大体积 700kb
maxAssetSize: 7168000,
//只给出 js 文件的性能提示
assetFilter: function(assetFilename) {
return assetFilename.endsWith('.js')
}
})
config.plugins.push(
new CompressionPlugin({
@@ -88,5 +81,12 @@ module.exports = {
deleteOriginalAssets: false,
})
)
}
// 添加 hash 到输出文件名
config.output = {
...config.output,
filename: 'js/[name].[hash:8].js',
chunkFilename: 'js/[name].[hash:8].js',
}
},
}