forked from PasteUs/PasteMeFrontend
-
Notifications
You must be signed in to change notification settings - Fork 0
/
vue.config.js
101 lines (97 loc) · 3.98 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
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
const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin;
// 取消用 tag 来区分版本
// const version = require("./build.config").version;
const version = 'master';
let webPath = 'https://cdn.jsdelivr.net/gh/PasteUs/CDN@' + version + '/pasteme/';
const cdn = {
// 开发环境
dev: {
css: [
"https://shadow.elemecdn.com/npm/[email protected]/dist/katex.min.css",
"https://cdn.staticfile.org/github-markdown-css/3.0.1/github-markdown.min.css",
"https://shadow.elemecdn.com/npm/[email protected]/dist/css/bootstrap.min.css",
"https://shadow.elemecdn.com/npm/[email protected]/dist/bootstrap-vue.min.css"
],
js: [
"https://cdn.jsdelivr.net/gh/highlightjs/[email protected]/build/highlight.min.js"
]
},
// 生产环境
build: {
css: [
"https://shadow.elemecdn.com/npm/[email protected]/dist/katex.min.css",
"https://cdn.staticfile.org/github-markdown-css/3.0.1/github-markdown.min.css",
"https://shadow.elemecdn.com/npm/[email protected]/dist/css/bootstrap.min.css",
"https://shadow.elemecdn.com/npm/[email protected]/dist/bootstrap-vue.min.css"
],
js: [
'https://shadow.elemecdn.com/npm/[email protected]/dist/vue.runtime.min.js',
'https://shadow.elemecdn.com/npm/[email protected]/dist/vue-router.min.js',
'https://shadow.elemecdn.com/npm/[email protected]/dist/vuex.min.js',
'https://shadow.elemecdn.com/npm/[email protected]/dist/axios.min.js',
'https://shadow.elemecdn.com/npm/[email protected]/dist/katex.min.js',
"https://shadow.elemecdn.com/npm/[email protected]/dist/mermaid.min.js",
"https://cdn.jsdelivr.net/gh/highlightjs/[email protected]/build/highlight.min.js",
"https://cdn.jsdelivr.net/npm/[email protected]/dist/d3.min.js",
"https://shadow.elemecdn.com/npm/[email protected]/dist/bootstrap-vue.min.js",
"https://cdn.jsdelivr.net/npm/[email protected]/dist/markdown-it.min.js",
"https://cdn.jsdelivr.net/npm/[email protected]/lib/unorm.min.js",
"https://cdn.jsdelivr.net/npm/@chenfengyuan/[email protected]/dist/vue-qrcode.min.js",
"https://cdn.jsdelivr.net/npm/[email protected]/dist/vue-i18n.min.js"
]
}
};
module.exports = {
devServer: {
proxy: {
"/api/v3/": {
secure: false,
target: "http://beta.pasteme.lucien.ink/",
// target: "http://localhost:8000/",
changeOrigin: true
}
}
},
publicPath: process.env.NODE_ENV === 'production' ? webPath : '/',
outputDir: 'pasteme',
productionSourceMap: false,
configureWebpack: config => { // eslint-disable-line
if (process.env.NODE_ENV === 'production') {
config.plugins.push(new BundleAnalyzerPlugin({
analyzerMode: "static"
}));
config.externals = {
"vue": "Vue",
"vuex": "Vuex",
"vue-router": "VueRouter",
"katex": "katex",
"axios": "axios",
"mermaid": "mermaid",
"highlight.js": "hljs",
"d3": "d3",
"bootstrap-vue": "BootstrapVue",
"markdown-it": "markdownit",
"unorm": "unorm",
"@chenfengyuan/vue-qrcode": "VueQrcode",
"vue-i18n": "VueI18n"
};
}
return {
output: {
libraryExport: 'default',
jsonpFunction: 'jsonpFunction'
}
}
},
chainWebpack: config => {
config.plugin('html').tap(args => {
if (process.env.NODE_ENV === 'production') {
args[0].cdn = cdn.build
}
if (process.env.NODE_ENV === 'development') {
args[0].cdn = cdn.dev
}
return args
})
}
};