forked from waifu-project/comic
-
Notifications
You must be signed in to change notification settings - Fork 5
/
vue.config.js
40 lines (36 loc) · 907 Bytes
/
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
const path = require('path')
const fs = require('fs')
const webpack = require('webpack')
const resolve = _p => path.join(__dirname, _p)
/**
* 拿到 `pages.json` 参考: https://www.npmjs.com/package/uni-vue-router
* @returns {string}
*/
const readPagesJSON = () => {
const jsonFilePath = resolve('./src/pages.json')
if (!fs.existsSync(jsonFilePath)) {
throw new Error(jsonFilePath + ' 不存在')
}
return fs.readFileSync(jsonFilePath, 'utf8')
}
/**
* 读取 `package.json` 文件
*/
const readPackageJson = () => {
return fs.readFileSync(resolve('./package.json'), 'utf-8')
}
module.exports = {
configureWebpack: {
plugins: [
new webpack.DefinePlugin({
PAGES_JSON: JSON.stringify(readPagesJSON()),
PACKAGES_JSON: JSON.stringify(readPackageJson())
})
]
},
transpileDependencies: [
"url-parse",
"normalize-url",
"url-regex",
]
}