Skip to content

Commit 1d3e9e1

Browse files
author
Guillaume Chau
committed
docs: webpack
1 parent a4ee8e4 commit 1d3e9e1

File tree

2 files changed

+34
-0
lines changed

2 files changed

+34
-0
lines changed

docs/.vuepress/config.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ module.exports = {
3939
'',
4040
'configuration',
4141
'directives',
42+
'webpack',
4243
],
4344
},
4445
},

docs/guide/webpack.md

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# Webpack configuration
2+
3+
In `api.chainWebpack` and `api.configureWebpack`, you have access to some environment variables:
4+
5+
- **`process.env.VUE_CLI_SSR_TARGET`**: Either `'client'` or `'server'`
6+
7+
- **`process.env.VUE_CLI_MODE`**: Vue CLI mode
8+
9+
Examples:
10+
11+
```js
12+
api.chainWebpack(config => {
13+
if (process.env.VUE_CLI_SSR_TARGET === 'client') {
14+
// Client-only config
15+
} else {
16+
// SSR-only config
17+
}
18+
})
19+
```
20+
21+
```js
22+
api.configureWebpack(config => {
23+
if (process.env.VUE_CLI_SSR_TARGET === 'client') {
24+
return {
25+
// Client-only config
26+
}
27+
} else {
28+
return {
29+
// SSR-only config
30+
}
31+
}
32+
})
33+
```

0 commit comments

Comments
 (0)