Skip to content

Commit dfe2412

Browse files
chriscaloAkryum
authored andcommitted
docs: Clarify that webpack config goes in vue.config.js (#142)
1 parent 05d3583 commit dfe2412

File tree

1 file changed

+30
-19
lines changed

1 file changed

+30
-19
lines changed

docs/guide/webpack.md

Lines changed: 30 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,44 @@
11
# Webpack configuration
22

3-
In `api.chainWebpack` and `api.configureWebpack`, you have access to some environment variables:
3+
In the `chainWebpack()` and `configureWebpack()` options `vue.config.js`, you have access to some environment
4+
variables:
45

56
- **`process.env.VUE_CLI_SSR_TARGET`**: Either `'client'` or `'server'`
67

78
- **`process.env.VUE_CLI_MODE`**: Vue CLI mode
89

9-
Examples:
10+
`vue.config.js`'s `chainWebpack()` option:
1011

1112
```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-
})
13+
module.exports = {
14+
// ...
15+
chainWebpack(config => {
16+
if (process.env.VUE_CLI_SSR_TARGET === 'client') {
17+
// Client-only config
18+
} else {
19+
// SSR-only config
20+
}
21+
}),
22+
// ...
23+
}
1924
```
2025

26+
`vue.config.js`'s `configureWebpack()` option:
27+
2128
```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
29+
module.exports = {
30+
// ...
31+
configureWebpack(config => {
32+
if (process.env.VUE_CLI_SSR_TARGET === 'client') {
33+
return {
34+
// Client-only config
35+
}
36+
} else {
37+
return {
38+
// SSR-only config
39+
}
3040
}
31-
}
32-
})
41+
}),
42+
// ...
43+
}
3344
```

0 commit comments

Comments
 (0)