const path = require("path") module.exports = { publicPath: '/', outputDir: process.env.outputDir, assetsDir: 'static', devServer: { host:'localhost', port: 8084, https: false, hotOnly: false, proxy: { '/v2': { target: process.env.NEW_VUE_APP_API_URL, changOrigin: true, pathRewrite: { "^/v2": ''} }, '/v1': { target: process.env.VUE_APP_API_URL, changOrigin: true, }, "/nav": { target: process.env.VUE_APP_CIDAPI_URL, changOrigin: true, }, '/idapi': { target: process.env.VUE_APP_TOKEN_URL, changOrigin: true, } } }, configureWebpack: { devtool: '#souce-map', resolve: { extensions: ['.js', '.vue', '.json'], alias: { "@/": path.resolve("src") } } }, chainWebpack: config => { // svg rule loader const svgRule = config.module.rule('svg') // 找到svg-loader svgRule.uses.clear() // 清除已有的loader, 如果不这样做会添加在此loader之后 svgRule.exclude.add(/node_modules/) // 正则匹配排除node_modules目录 svgRule // 添加svg新的loader处理 .test(/\.svg$/) .use('svg-sprite-loader') .loader('svg-sprite-loader') .options({ symbolId: 'icon-[name]', }) // 修改images loader 添加svg处理 const imagesRule = config.module.rule('images') imagesRule.exclude.add(path.resolve('src/assets/icons')) config.module .rule('images') .test(/\.(png|jpe?g|gif|svg)(\?.*)?$/) } }