- Sponsor
-
Notifications
You must be signed in to change notification settings - Fork 61
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
Replacing process.env.NODE_ENV
#274
Comments
Yes, this options does not exist in v4 (not sure whether exists in v3). Should be fixed. |
@CrashyBang hi, I study the source code a bit and find a workaround to bypass this problem under current version. Bili can resolve custom plugins with options, but rollup-plugin-replace is a built-in plugin of Bili and has some internal options. Here: pluginsOptions.replace = {
...config.plugins.replace,
values: {
...Object.keys(env).reduce((res: Env, name) => {
res[`process.env.${name}`] = JSON.stringify(env[name])
return res
}, {}),
...(config.plugins.replace && config.plugins.replace.values)
}
} in rollup-plugin-replace (source), values takes precedence over replace so the plugins: {
replace: {
values: {
'process.env.NODE_ENV': JSON.stringify('production'),
},
},
}, BTW, this is really a trap. Should be pointed out in documentation. 😅 update: We will upgrade to @rollup/plugin-replace. And stoo using |
🎉 This issue has been resolved in version 4.9.2 🎉 The release is available on: Your semantic-release bot 📦🚀 |
I am aware of #19 however this functionality appears to have been removed.
I have tried implementing this manually using
babel-plugin-transform-define
by adding the following to mybabel.config.js
plugins config:However this seems to be having no effect on the compiled output, I could do this via
@rollup/plugin-replace
as demonstrated in this comment but doing it viababel
will convert things likeprocess.env.NODE_ENV === "production"
totrue
in the compiled output which I prefer.Cheers.
UPDATE
Using:
Still does not effect compiled output.
The text was updated successfully, but these errors were encountered: