vue.config.js
2.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
const { defineConfig } = require("@vue/cli-service");
const Spritesmith = require("webpack-spritesmith");
const path = require("path");
const templateFunction = require("./sprite");
// const {
// VantResolver,
// ElementPlusResolver,
// } = require("unplugin-vue-components/resolvers");
// const ComponentsPlugin = require("unplugin-vue-components/webpack");
function resolve(dir) {
return path.join(__dirname, ".", dir);
}
module.exports = defineConfig({
publicPath: "./",
transpileDependencies: true,
devServer: {
port: 9527,
proxy: {
'/api': {
target: 'https://eshield.dev.glsx.com.cn/',
changeOrigin: true,
secure: false,
pathRewrite: { "^/api": "" },
}
}
},
chainWebpack: (config) => {
config.plugin("webpack-spritesmith").use(Spritesmith, [
{
src: {
cwd: path.resolve(__dirname, "src/assets/icon"),
glob: "*.png",
},
target: {
image: path.resolve(
__dirname,
"src/assets/spritesmith-generated/sprite.png"
),
css: [
[
path.resolve(
__dirname,
"src/assets/spritesmith-generated/sprite.css"
),
{
format: "function_based_template",
},
],
],
},
customTemplates: {
function_based_template: templateFunction,
},
apiOptions: {
cssImageRef: "sprite.png",
},
},
]);
config.module.rules.delete("svg"); // 重点:删除默认配置中处理svg,
config.module
.rule("svg-sprite-loader")
.test(/\.svg$/)
.include.add(resolve("src/assets/icons")) // 处理svg目录
.end()
.use("svg-sprite-loader")
.loader("svg-sprite-loader")
.options({
symbolId: "icon-[name]",
});
},
configureWebpack: {
// plugins: [
// ComponentsPlugin({
// resolvers: [VantResolver(), ElementPlusResolver()],
// }),
// ],
externals: {
wx: "wx",
},
},
});