-
Notifications
You must be signed in to change notification settings - Fork 16
/
vue.config.js
127 lines (116 loc) · 3.25 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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
const path = require('path')
const fs = require('fs')
const webpack = require('webpack')
const PrerenderSpaPlugin = require('prerender-spa-plugin')
const HtmlWebpackInlineSourcePlugin = require('html-webpack-inline-source-plugin')
const TerserPlugin = require('terser-webpack-plugin')
const packageDependencies = require('./package-lock.json').dependencies
const webpackPlugins = []
let certs = {}
if (process.env.NODE_ENV === 'production') {
webpackPlugins.push(new HtmlWebpackInlineSourcePlugin())
webpackPlugins.push(
new PrerenderSpaPlugin({
staticDir: path.join(__dirname, 'dist'),
routes: ['/'],
renderer: new PrerenderSpaPlugin.PuppeteerRenderer({
injectProperty: '__PRERENDERING',
inject: true,
renderAfterDocumentEvent: 'render-event',
skipThirdPartyRequests: true
}),
postProcess(context) {
// context.html = context.html.replace('id="drawmote"', 'id="drawmote" data-server-rendered="true"')
return context
}
})
)
} else {
certs = {
key: fs.readFileSync('./cert/server-key.pem'),
cert: fs.readFileSync('./cert/server-crt.pem'),
ca: fs.readFileSync('./cert/ca-crt.pem')
}
}
const dependencies = {}
new Array('gymote', 'peersox', 'vuetamin', 'lazy-brush').forEach((name) => {
dependencies[name] = packageDependencies[name].version
})
webpackPlugins.push(
new webpack.DefinePlugin({
DEPENDENCIES: JSON.stringify(dependencies)
})
)
module.exports = {
productionSourceMap: true,
filenameHashing: true,
transpileDependencies: ['debounced-resize', 'peersox'],
pluginOptions: {
'style-resources-loader': {
preProcessor: 'scss',
patterns: [path.resolve(__dirname, 'src/assets/scss/vue_include.scss')]
},
i18n: {
locale: 'en',
fallbackLocale: 'en',
localeDir: 'locales',
enableInSFC: false
}
},
devServer: {
https: {
...certs
}
},
configureWebpack: {
optimization: {
minimizer:
process.env.NODE_ENV === 'production'
? [
new TerserPlugin({
sourceMap: true,
terserOptions: {
ecma: 5,
module: true,
toplevel: true
}
})
]
: []
},
resolve: {
symlinks: false
},
plugins: webpackPlugins
},
chainWebpack: (config) => {
config.optimization.delete('splitChunks')
config.optimization.splitChunks(false)
config.plugin('define').tap((args) => {
let v = JSON.stringify(require('./package.json').version)
args[0]['process.env']['PKG_VERSION'] = v
return args
})
if (process.env.NODE_ENV === 'production') {
config.plugin('preload').tap((args) => {
args[0].fileBlacklist.push(/\.css$/)
return args
})
config.plugin('html').tap((args) => {
args[0].inlineSource = '.(css)$'
return args
})
}
if (process.env.NODE_ENV === 'development') {
config.output.filename('[name].[hash].js').end()
}
const svgRule = config.module.rule('svg')
svgRule.uses.clear()
svgRule
.use('babel-loader')
.loader('babel-loader')
.end()
.use('vue-svg-loader')
.loader('vue-svg-loader')
}
}