-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathvue.config.js
58 lines (54 loc) · 1.57 KB
/
vue.config.js
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
// eslint-disable-next-line @typescript-eslint/no-var-requires
const path = require('path');
// eslint-disable-next-line @typescript-eslint/no-var-requires
const styleVariables = require('./src/utils/variables.ts');
const publicPath = './';
module.exports = {
publicPath, // 根据你的实际情况更改这里
productionSourceMap: false,
css: {
loaderOptions: {
scss: {
prependData: Object.keys(styleVariables)
// eslint-disable-next-line no-useless-escape
.map(k => `\$${k}: ${styleVariables[k]};`)
.join('\n') + `
@import "@/assets/scss/_base.scss";
`
}
}
},
pages: {
index: {
entry: 'src/main.ts',
title: process.env.VUE_APP_NAME,
}
},
chainWebpack: config => {
const svgRule = config.module.rule('svg');
// 清除已有的所有 loader。
// 如果你不这样做,接下来的 loader 会附加在该规则现有的 loader 之后。
svgRule.uses.clear();
svgRule
.test(/\.svg$/)
.include.add(path.resolve(__dirname, './src/assets/svg'))
.end()
.use('svg-sprite-loader')
.loader('svg-sprite-loader')
.options({
symbolId: 'icon-[name]'
});
const fileRule = config.module.rule('file');
fileRule.uses.clear();
fileRule
.test(/\.svg$/)
.exclude.add(path.resolve(__dirname, './src/assets/svg'))
.end()
.use('file-loader')
.loader('file-loader');
},
transpileDependencies: ['element-plus/src', 'element-plus/packages'],
devServer: {
historyApiFallback: true
}
};