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
Environment variables not detected when used in config file from an imported source #9688
Comments
@dvlden In full static mode, Nuxt tries to skip a webpack rebuild where possible. To avoid rebuilding every time an unimportant env variable changes, Nuxt checks your export default {
generate: {
cache: false
}
} |
@danielpost That works, but slows down the repeated process, as it doesn't cache anything. "To avoid rebuilding when an unimportant env variable changes, Nuxt checks your nuxt.config for usage." |
@dvlden The reason is that detecting usage becomes much more complicated once there is an import tree to trace. PRs are definitely welcome. For now, a workaround could be to include the environment variables - even just in a comment - in your // process.env.MY_CONFIG, process.env.MY_OTHER_CONFIG
export default {
// ...
} |
A new /note: For nuxi/nuxt3 we should try a proxy-based implementation to track |
Perfect! |
Versions
Reproduction
https://github.com/dvlden/nuxt-generate-bug
Steps to reproduce
yarn run generate
dist/index.html
, the custom meta tag will contain value ofAPP_SPECIAL
env. variable, which isholy.sh
.env
file by changingAPP_SPECIAL
to something elseyarn run generate
dist/index.html
, the custom meta tag will remain untouched, the meta content will be what it was initiallyrm -rf dist .nuxt
yarn run generate
What is Expected?
All
process.env
variables should exist so that their change can be tracked. This isn't the case when something is imported insidenuxt.config.js
and used for configuration.What is actually happening?
It seems that nuxt doesn't pick up env. variables that appear to be unused?
If you inspect
@nuxt/cli/dist/cli-generate.js
and log thecurrentBuild
, you'll notice thatprocess.env
only containsAPP_SOMETHING
which is used innuxt.config.js
directly, through the constant.However,
APP_SPECIAL
is non-existent withinprocess.env
, but it's being imported from a file and used in example to create contents of a meta tag. I assume we could've use the imported constant for some other purpose too and it wouldn't detect a change.This problem is happening for all
nuxt
scripts, not justgenerate
.The text was updated successfully, but these errors were encountered: