-
-
Notifications
You must be signed in to change notification settings - Fork 6.3k
A way to detect modern/legacy build #2921
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
You can generate multiple arguments based bundles.
|
@cainrus this way I can only detect modern mode, but not modern build. Because in modern mode 2 builds are created: legacy and modern. |
We use this line to detect modern/legacy build internally:
Though it's not a good practice to rely on internal flags, you can use the two environment variables as a workaround for now. |
@sodatea I tried, but they are not available in client code |
// vue.config.js
module.exports = {
chainWebpack: config =>
config
.plugin('define')
.tap(options => {
options[0]['process.env']['IS_MODERN_BUILD'] = process.env.VUE_CLI_MODERN_BUILD
return options
})
} |
@sodatea thank you! This works as expected.
|
@Djaler Maybe it's because there's already a |
@sodatea Whould there be any concern with exposing this flag as a public API by mentioning it in the docs? I don't see a clever way of making this available without an env variable. To keep internals separate, we could introduce a different env variable for the public that (for now) just is set alongside |
@LinusBorg Yeah I just reconsidered this issue and found no better way to achieve this. It should be documented somewhere, along with the recommended way to use it ( The naming seems fine as it reflects the fact that it is expected to be used in a Vue CLI build config file. |
* Add tip abouit detecting modern mode close #2921 * add note about postcss * docs: fix typo and format [ci skip]
What problem does this feature solve?
I use css variables in my application. But they are not supported in old browsers. Because of this I need to use css-vars-ponyfill. But call to this library is necessary only in old browsers. And because of this I need a way to detect modern/legacy build to include this code only in legacy build.
What does the proposed API look like?
I think, information about current build type could be accessed via
process.env
variable.For example:
process.env.IS_MODERN_BUILD
The text was updated successfully, but these errors were encountered: