-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathvue.config.js
51 lines (49 loc) · 1.17 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
const fs = require('fs')
const glob = require("glob")
const px2vw = require("postcss-px-to-viewport")
const pages = {}
let entries
try {
// 获取相关入口
entries = glob('src/views/*/index.js', {sync: true})
} catch (err) {
entries = []
throw err
}
// 格式化生成入口
entries.forEach((file) => {
// file字符串为 src/views/.../index.js
const fileSplit = file.split('/')
const pageName = fileSplit[2]
let pageHtml = fileSplit.slice(0, 3).join('/') + '/index.html'
if (!fs.existsSync(pageHtml)) {
// 入口如果不配置直接使用 _default.html
pageHtml = fileSplit.slice(0, 2).join('/') + '/_default.html'
}
pages[pageName] = {
entry: file,
template: pageHtml,
filename: `${pageName}.html`
}
})
module.exports = {
pages,
css: {
loaderOptions: {
css: {
// options here will be passed to css-loader
},
postcss: {
plugins: () => [px2vw({
viewportWidth: 750,
viewporHeight: 134,
unitPrecision: 3,
viewportUnit: 'vw',
selectorBlackList: ['.ignore', '.hairlines'],
minPixelValue: 1,
mediaQuery: false
})]
}
}
}
}