-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvue.config.js
More file actions
71 lines (66 loc) · 1.92 KB
/
vue.config.js
File metadata and controls
71 lines (66 loc) · 1.92 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
const path = require('path')
// 分析包内容
const BundleAnalyzerPlugin = require('webpack-bundle-analyzer')
.BundleAnalyzerPlugin
const ServiceWorkerWebpackPlugin = require('serviceworker-webpack-plugin')
// const PrerenderSPAPlugin = require('prerender-spa-plugin')
// const Renderer = PrerenderSPAPlugin.PuppeteerRenderer
function resolve(dir) {
return path.join(__dirname, dir)
}
let vueCdn = process.env.NODE_ENV === 'production' ? 'vue.min.js' : 'vue.js'
let configureWebpack = {
// provide the app's title in webpack's name field, so that
// it can be accessed in index.html to inject the correct title.
resolve: {
alias: {
'@': resolve('src'),
'@assets': resolve('src/assets'),
'bn.js': path.resolve(process.cwd(), 'node_modules', 'bn.js')
}
}
}
if (process.env.NODE_ENV === 'production') {
configureWebpack['externals'] = {
vue: 'Vue'
}
}
module.exports = {
productionSourceMap: process.env.NODE_ENV === 'production' ? false : true,
configureWebpack,
publicPath:
process.env.NODE_ENV === 'production'
? '//output-1303179205.file.myqcloud.com/output/'
: '/',
chainWebpack(config) {
let css = [],
js = []
if (process.env.NODE_ENV === 'production') {
css = [
// element-ui css
// 'https://lib.baomitu.com/element-ui/2.14.1/theme-chalk/index.css'
]
js = [
`https://lib.baomitu.com/vue/2.6.12/${vueCdn}`
// element-ui js
// 'https://lib.baomitu.com/element-ui/2.14.1/index.js'
]
}
const cdn = {
css,
js
}
config.plugin('html').tap(args => {
args[0].cdn = cdn
return args
})
config.module.rule('eslint').use('eslint-loader')
config.plugin('sw').use(ServiceWorkerWebpackPlugin, [
{
entry: path.join(__dirname, 'src/sw.js')
}
])
process.env.ENV_ANALYZE === '1' &&
config.plugin('analyzer').use(BundleAnalyzerPlugin)
}
}