-
Notifications
You must be signed in to change notification settings - Fork 4.7k
/
Copy pathcreateClientConfig.js
77 lines (67 loc) · 2.07 KB
/
createClientConfig.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
'use strict'
/**
* Expose createClientConfig method.
*/
module.exports = function createClientConfig (ctx) {
const { path, env } = require('@vuepress/shared-utils')
const createBaseConfig = require('./createBaseConfig')
const config = createBaseConfig(ctx)
config
.entry('app')
.add(path.resolve(__dirname, '../app/clientEntry.js'))
config.node
.merge({
// prevent webpack from injecting useless setImmediate polyfill because Vue
// source contains it (although only uses it if it's native).
setImmediate: false,
global: false,
process: false,
// prevent webpack from injecting mocks to Node native modules
// that does not make sense for the client
dgram: 'empty',
fs: 'empty',
net: 'empty',
tls: 'empty',
child_process: 'empty'
})
// generate client manifest only during build
if (process.env.NODE_ENV === 'production') {
// This is a temp build of vue-server-renderer/client-plugin.
// TODO Switch back to original after problems are resolved.
// Fixes two things:
// 1. Include CSS in preload files
// 2. filter out useless styles.xxxxx.js chunk from mini-css-extract-plugin
// https://github.com/webpack-contrib/mini-css-extract-plugin/issues/85
config
.plugin('ssr-client')
.use(require('./ClientPlugin'), [{
filename: 'manifest/client.json'
}])
config
.plugin('optimize-css')
.use(require('optimize-css-assets-webpack-plugin'), [{
canPrint: false,
cssProcessorOptions: {
safe: true,
autoprefixer: { disable: true },
mergeLonghand: false
}
}])
} else {
config
.plugin('hmr')
.use(require('webpack/lib/HotModuleReplacementPlugin'))
}
if (!env.isDebug) {
const WebpackBar = require('webpackbar')
config
.plugin('bar')
.use(WebpackBar, [{
name: 'Client',
color: '#41b883',
compiledIn: false
}])
}
ctx.pluginAPI.options.chainWebpack.syncApply(config, false /* isServer */)
return config
}