chainWebpack: config => {
config.resolve.alias.set('@$', resolve('src'))
// 移除 prefetch 插件 (处理首页懒加载路由文件500+导致登录页卡顿的问题)
config.plugins.delete('prefetch')
const svgRule = config.module.rule('svg')
svgRule.uses.clear()
svgRule
.oneOf('inline')
.resourceQuery(/inline/)
.use('vue-svg-icon-loader')
.loader('vue-svg-icon-loader')
.end()
.end()
.oneOf('external')
.use('file-loader')
.loader('file-loader')
.options({
name: 'assets/[name].[hash:8].[ext]'
})
// if prod is on
// assets require on cdn
if (isProd) {
config.plugin('html').tap(args => {
args[0].cdn = assetsCDN
return args
})
}
}
原文:https://segmentfault.com/a/1190000019499007