-
-
Notifications
You must be signed in to change notification settings - Fork 6.9k
/
client.js
68 lines (56 loc) 路 1.52 KB
/
client.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
// Imports
const HtmlWebpackPlugin = require('html-webpack-plugin')
const metadata = require('../../../src/data/metadata')
const VueSSRClientPlugin = require('vue-server-renderer/client-plugin')
// Globals
const IS_PROD = process.env.NODE_ENV === 'production'
process.env.VUE_ENV = 'client'
function useMetadata (template, filename) {
return [{
template: `src/${template}.template.html`,
filename: `${filename || `_${template}`}.html`,
...metadata,
}]
}
module.exports = config => {
require('./base')(config)
config
.entry('app')
.clear()
.add('./src/entry-client.js')
.end()
config.plugin('VueSSRClientPlugin')
.use(VueSSRClientPlugin)
config.plugin('html-spa')
.use(HtmlWebpackPlugin, useMetadata('spa', '_fallback'))
config.plugin('html-crowdin')
.use(HtmlWebpackPlugin, useMetadata('crowdin'))
config.plugin('pwa').after('html-spa')
config.optimization
.splitChunks({
cacheGroups: {
vuetify: {
test: /[\\/]vuetify[\\/]lib[\\/]/,
enforce: true,
},
},
chunks: 'all',
maxAsyncRequests: 20,
maxInitialRequests: 5,
minSize: 20000,
})
config.optimization
.minimize(IS_PROD)
.minimizer('css')
.use(require('terser-webpack-plugin'))
.use(require('css-minimizer-webpack-plugin'), [{
minimizerOptions: { safe: true },
}])
config.target('web')
config.module
.rule('json')
.resourceQuery(/blockType=codepen-resources/)
.use('json')
.loader('json-loader')
.end()
}