-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathvue.config.js
55 lines (53 loc) · 1.19 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
const fs = require('fs')
const glob = require("glob")
// 简单学习 glob https://www.cnblogs.com/liulangmao/p/4552339.html
const pages = {}
let entries
try {
entries = glob('src/pages/*/main.js', {sync: true})
} catch (err) {
entries = []
throw err
}
entries.forEach((file) => {
const fileSplit = file.split('/')
const pageName = fileSplit[2]
let pageHtml = fileSplit.slice(0, 3).join('/') + '/index.html'
if (!fs.existsSync(pageHtml)) {
pageHtml = fileSplit.slice(0, 2).join('/') + '/_default.html'
}
pages[pageName] = {
entry: file,
template: pageHtml,
filename: `${pageName}.html`
}
})
module.exports = {
pages,
baseUrl: '/',
outputDir: 'dist',
lintOnSave: true,
chainWebpack: (config) => {
const env = (process.env.VUE_APP_ENV).toUpperCase()
console.log(`当前环境: ${env}`)
},
productionSourceMap: true,
css: {
extract: true,
sourceMap: false,
loaderOptions: {}
},
parallel: require('os').cpus().length > 1,
pluginOptions: {},
devServer: {
open: false,
disableHostCheck: true,
host: '0.0.0.0',
port: 8000,
https: false,
hotOnly: false,
proxy: null, // string | Object
before: (app) => {
}
}
}