Skip to content

Commit 2ab93e7

Browse files
LinusBorghaoqunjiang
authored andcommitted
docs: add tip about detecting modern mode (#3108) [ci skip]
* Add tip abouit detecting modern mode close #2921 * add note about postcss * docs: fix typo and format [ci skip]
1 parent d217d75 commit 2ab93e7

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

docs/guide/browser-compatibility.md

+11
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,17 @@ Content-Security-Policy: script-src 'self' 'sha256-4RS22DYeB7U14dra4KcQYxmwt5HkO
7878
```
7979
:::
8080

81+
::: tip Detecting the Current Mode in Config
82+
Sometimes you may need to change the webpack config only for the legacy build, or only for the modern build.
83+
84+
Vue CLI uses two environment variables to communicate this:
85+
86+
* `VUE_CLI_MODERN_MODE`: The build was started with the `--modern` flag
87+
* `VUE_CLI_MODERN_BUILD`: when true, the current config is for the modern build. Otherwise it's for the legacy build.
88+
89+
**Important:** These variables are only accessible when/after `chainWebpack()` and `configureWebpack()` functions are evaluated, (so not directly in the `vue.config.js` module's root scope). That means it's also available in the postcss config file.
90+
:::
91+
8192
[autoprefixer]: https://github.com/postcss/autoprefixer
8293
[babel-preset-env]: https://new.babeljs.io/docs/en/next/babel-preset-env.html
8394
[babel-preset-app]: https://github.com/vuejs/vue-cli/tree/dev/packages/%40vue/babel-preset-app

0 commit comments

Comments
 (0)