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
[Bug?]: Cannot use environment variable in redwood.toml for sourceMap
option
#10214
Comments
sourceMap
optionsourceMap
option
Hey @oliwheeler 👋 So our TOML config parsing happens here with these two functions: redwood/packages/project-config/src/config.ts Lines 205 to 229 in 0b18504
You can see why this is causing the behaviour you didn't quite expect. We perform the env interpolation before we parse the toml. This means we'd do the following during our env interpolation stage:
Then when this is parsed from TOML it'll be a string "false", which is truthy and so we get the problem you raise here. One workaround is to avoid passing an alternative option so: Another workaround is to avoid quotation marks so: I'm not sure what we could do to avoid this happening. We likely lack enough information to be able to do anything like transform I'd be good to hear more about what you'd have expected and how we can make this less confusing or unexpected. Would a warning in our docs in that section you linked to have been helpful? |
Thank you for the explanation! I just tried the first workaround but for some reason that still produces source maps. The second workaround works but as you say, it's not valid so red squiggles. Rather than having ENV VAR's within the config, is it in the cards to be able to supply the path to the TOML file as a CLI command parameter? Like |
It's not on the cards at the moment but let me think the problem over a little bit more and have a talk with some of the team about it. This isn't blocking you at the moment right? |
Not blocking at all :) |
Hey @oliwheeler could you try: I confirmed that I was wrong with This doesn't feel particularly ergonomic and I will bring it up with the team. However, I suspect we're unlikely to carve out some dedicated time ourselves to implement anything to make this work better in the near future just because of priorities. |
Thanks! The new solution with the space works :) |
What's not working?
As described here, it's possible to use environment variables in redwood.toml.
However, since
sourceMap
is a boolean option, it casts the string"false"
to booleantrue
.So
sourceMap = "${SOURCE_MAP_ENABLED:false}"
gets interpeted as true whenSOURCE_MAP_ENABLED
is unset.How do we reproduce the bug?
sourceMap = "${SOURCE_MAP_ENABLED:false}"
in the redwood.toml file.web/dist/assets
What's your environment? (If it applies)
No response
Are you interested in working on this?
The text was updated successfully, but these errors were encountered: