8000 add DefinePlugin to webpack example config · vuejs/vue2-ssr-docs@9cad699 · GitHub
[go: up one dir, main page]

Skip to content

Commit 9cad699

Browse files
authored
add DefinePlugin to webpack example config
We need to demonstrate how to pass VUE_ENV to the app
1 parent 5ffb9af commit 9cad699

File tree

1 file changed

+19
-5
lines changed

1 file changed

+19
-5
lines changed

docs/guide/build-config.md

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,18 @@ module.exports = merge(baseConfig, {
4040
whitelist: /\.css$/
4141
}),
4242

43-
// This is the plugin that turns the entire output of the server build
44-
// into a single JSON file. The default file name will be
45-
// `vue-ssr-server-bundle.json`
43+
4644
plugins: [
47-
new VueSSRServerPlugin()
45+
// This is the plugin that turns the entire output of the server build
46+
// into a single JSON file. The default file name will be
47+
// `vue-ssr-server-bundle.json`
48+
new VueSSRServerPlugin(),
49+
// To make Vue.prototype.$isServer work, we have to make `VUE_ENV` available
50+
// in the bundled application
51+
new webpack.DefinePlugin({
52+
'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV || 'development'),
53+
'process.env.VUE_ENV': '"server"'
54+
}),
4855
]
4956
})
5057
```
@@ -102,7 +109,14 @@ module.exports = merge(baseConfig, {
102109
}),
103110
// This plugins generates `vue-ssr-client-manifest.json` in the
104111
// output directory.
105-
new VueSSRClientPlugin()
112+
new VueSSRClientPlugin(),
113+
114+
// To make Vue.prototype.$isServer work, we have to make `VUE_ENV` available
115+
// in the bundled application
116+
new webpack.DefinePlugin({
117+
'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV || 'development'),
118+
'process.env.VUE_ENV': '"server"'
119+
}),
106120
]
107121
})
108122
```

0 commit comments

Comments
 (0)
0