Repository navigation
Expand file tree
/
Copy pathvue.config.js
More file actions
141 lines (120 loc) · 3.13 KB
/
Copy pathvue.config.js
File metadata and controls
141 lines (120 loc) · 3.13 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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
const path = require('path')
function resolve (dir) {
return path.join(__dirname, dir)
}
const ProxyURL = 'https://theme-template-lite.wodavip.com' // https://theme-template-lite.wodavip.com
module.exports = {
devServer: {
headers: {
'Access-Control-Allow-Origin': '*'
},
proxy: {
'/api': {
target: ProxyURL,
ws: false,
changeOrigin: true,
headers: {
referer: ProxyURL,
origin: ProxyURL
}
}
}
},
configureWebpack: config => {
config.output.filename = '[name].raw.js'
config.output.chunkFilename = '[id]-[chunkhash].raw.js'
},
chainWebpack: config => {
// ESLint
config.module
.rule('eslint')
.use('eslint-loader')
.tap(options => {
options.fix = true // Auto Fix
return options
})
.end()
// Docs Block
// 后面加上输出原始文本
// ExtractTextPlugin.extract('raw-loader') & new ExtractTextPlugin('docs.md')
config.module
.rule('docs')
.resourceQuery(/blockType=docs/)
.use('raw-loader')
.loader('raw-loader')
.end()
// Shop UI SVG Sprite
config.module
.rule('shop-ui-svg')
.test(/\.svg$/)
.include
.add(resolve('src/shop-ui/icons'))
.end()
.use('file-loader') // 修改原 SVG Rule 的
.loader('svg-sprite-loader')
.tap(options => {
const _options = options || {}
delete _options.name
_options.symbolId = 'su-icon-[name]'
return _options
})
.end()
// Shop Kit SVG Sprite
config.module
.rule('shop-kit-svg')
.test(/\.svg$/)
.include
.add(resolve('src/shop-kit/icons'))
.end()
.use('file-loader') // 修改原 svg Rule 的
.loader('svg-sprite-loader')
.tap(options => {
const _options = options || {}
delete _options.name
_options.symbolId = 'sk-icon-[name]'
return _options
})
.end()
// SVG Sprite
const iconsDir = resolve('src/icons')
config.module
.rule('svg')
.test(/\.svg$/)
.include
.add(iconsDir)
.end()
.use('file-loader') // 修改原 svg Rule 的
.loader('svg-sprite-loader')
.tap(options => {
const _options = options || {}
delete _options.name
_options.symbolId = filePath => {
const oPath = path.parse(filePath)
const dirs = oPath.dir.replace(iconsDir).split(path.sep)
const prefix = dirs.slice(2).join('-') // 只获取 svg 的子目录
return `icon-${prefix ? (prefix + '-') : ''}${oPath.name}`
}
return _options
})
.end()
// Delete Plugins
// config.plugins.delete('preload')
config.plugins.delete('prefetch')
},
filenameHashing: false,
productionSourceMap: false,
css: {
extract: !(process.env.NODE_ENV === 'production') ? false : {
filename: '[name].raw.css',
chunkFilename: '[id]-[chunkhash].raw.css'
}
},
pluginOptions: {
i18n: {
locale: 'zh-CN',
fallbackLocale: 'en',
localeDir: 'locales',
enableInSFC: true
}
}
}