-
Notifications
You must be signed in to change notification settings - Fork 0
/
vue.config.js
63 lines (59 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
59
60
61
62
63
// ESLint ignore first line
/* eslint-disable */
const path = require('path')
/*
function resolve(dir) {
return path.join(__dirname, dir)
}
*/
module.exports = {
configureWebpack: {
resolve: {
alias: {
'vue2': path.join(__dirname, './node_modules/vue/dist/vue.esm.js'),
'vue.2': './node_modules/vue/dist/vue.esm.js',
'@': path.resolve(__dirname, './src')
},
extensions: ['.ts', '.jsx', '.tsx']
},
module: {
rules: [{
test: /\.(jsx|tsx|ts)$/,
loader: 'babel-loader'
}]
}
},
publicPath: process.env.NODE_ENV === 'production'
? '/vueel-demo/'
: '/',
lintOnSave: false,
css: {
requireModuleExtension: true
},
chainWebpack: config => {
const dir = path.resolve(__dirname, 'src/assets/icons') // 确定目录
config.module.rule('svg').uses.clear() //
config.module
.rule('svg-sprite')
.test(/\.svg$/) // .test(/\.(svg)(\?.*)?$/)
.include.add(dir).end() // 指定 仅包含 icons 的目录
.use('svg-sprite-loader').loader('svg-sprite-loader')
.options({extract: false}).end() // 不解析出文件
.use('svgo-loader').loader('svgo-loader')
.tap(options => ({
...options,
plugins: [{removeAttrs: {attrs: 'fill'}}]
}))
.end()
config.plugin('svg-sprite')
.use(
require('svg-sprite-loader/plugin'),
[{plainSprite: true}]
)
config.module.rule('svg').exclude.add(dir)// 其他 svg loader 排除 icons 目录
},
transpileDependencies: [
'vue-echarts',
'resize-detector'
]
}