diff --git a/docs/guide/webpack.md b/docs/guide/webpack.md index eb82d90..264a72a 100644 --- a/docs/guide/webpack.md +++ b/docs/guide/webpack.md @@ -1,33 +1,44 @@ # Webpack configuration -In `api.chainWebpack` and `api.configureWebpack`, you have access to some environment variables: +In the `chainWebpack()` and `configureWebpack()` options `vue.config.js`, you have access to some environment +variables: - **`process.env.VUE_CLI_SSR_TARGET`**: Either `'client'` or `'server'` - **`process.env.VUE_CLI_MODE`**: Vue CLI mode -Examples: +`vue.config.js`'s `chainWebpack()` option: ```js -api.chainWebpack(config => { - if (process.env.VUE_CLI_SSR_TARGET === 'client') { - // Client-only config - } else { - // SSR-only config - } -}) +module.exports = { + // ... + chainWebpack(config => { + if (process.env.VUE_CLI_SSR_TARGET === 'client') { + // Client-only config + } else { + // SSR-only config + } + }), + // ... +} ``` +`vue.config.js`'s `configureWebpack()` option: + ```js -api.configureWebpack(config => { - if (process.env.VUE_CLI_SSR_TARGET === 'client') { - return { - // Client-only config - } - } else { - return { - // SSR-only config +module.exports = { + // ... + configureWebpack(config => { + if (process.env.VUE_CLI_SSR_TARGET === 'client') { + return { + // Client-only config + } + } else { + return { + // SSR-only config + } } - } -}) + }), + // ... +} ```