Skip to content

Commit 11ca8b9

Browse files
authored
Add tip abouit detecting modern mode
close #2921
1 parent ad9ef4c commit 11ca8b9

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

docs/guide/browser-compatibility.md

Lines changed: 11 additions & 0 deletions
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 in `chainWebpack()` and `configureWebpack()` functions, not in the `vue.config.js` file's root scope.
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)