webpack.DefinePlugin and process.env.DEBUG
See original GitHub issueMy webpack config:
...
plugins: [
new webpack.DefinePlugin({
'process.env': {
NODE_ENV: JSON.stringify('production'),
DEBUG: true
}
})
],
target: 'electron-main',
...
So webpack changes
process.env.DEBUG = namespaces;
to
true = namespaces;
which leading to error
ReferenceError: Invalid left-hand side in assignment
Issue Analytics
- State:
- Created 6 years ago
- Reactions:6
- Comments:15 (4 by maintainers)
Top Results From Across the Web
webpack.DefinePlugin and process.env.DEBUG · Issue #467
My webpack config: ... plugins: [ new webpack.DefinePlugin({ 'process.env': { NODE_ENV: JSON.stringify('production'), DEBUG: true } }) ], target: ...
Read more >EnvironmentPlugin | webpack
webpack is a module bundler. ... EnvironmentPlugin is shorthand for using the DefinePlugin on process.env keys. ... NODE_ENV is defined DEBUG: false, }); ......
Read more >EnvironmentPlugin
The EnvironmentPlugin is shorthand for using the DefinePlugin on process.env keys. Usage. The EnvironmentPlugin accepts either an array of keys or an object ......
Read more >Passing environment-dependent variables in webpack
There are two basic ways to achieve this. DefinePlugin. new webpack.DefinePlugin({ 'process.env.NODE_ENV': JSON.stringify(process.env.
Read more >Environment Variables : Webpack config using DefinePlugin
What is Environment Variable ? “Environment variables are a set of dynamic named values that can affect the way running processes will behave...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I know this is painful for some users, but
debug
is not the place to properly fix this. Instead, webpack needs to solve this asprocess.env
has a very clear contract for what should be in it.It is not
debug
’s job to clean up other peoples’ messes. Please open a ticket with them as this is indeed a bug or poor devexp on their part.@wontem you have to escape values that you want assigned to actual variables. Otherwise, Webpack is going to REPLACE the variables with literal values.
Should look like this, afaik: