question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

webpack change the electron render env

See original GitHub issue

Bug report

What is the current behavior?

If the current behavior is a bug, please provide the steps to reproduce.

What is the expected behavior? when i use process.env with webpack in electron renderer process it show empty object {} but without webpack process.env working ok.

Other relevant information: webpack version: latest Node.js version: Operating System: ubuntu Additional tools: electron

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:6

github_iconTop GitHub Comments

1reaction
13bandacommented, Feb 9, 2019

thanks @misterdev

0reactions
misterdevcommented, Feb 9, 2019

I’ve executed npm run eject to see how webpack in configured in create-react-app. You can see here that in env.jsit filters the process.env keys including only those starting with REACT_APP_, NODE_ENV and PUBLIC_URL.

screenshot 2019-02-09 at 00 52 14

In the webpack configuration this filtered version of the process.env is replaced in the source code using the DefinePlugin

screenshot 2019-02-09 at 01 09 23

The process process.env is intentionally nearly empty, this isn’t a problem with Webpack but a create-react-app configuration 😃

Read more comments on GitHub >

github_iconTop Results From Across the Web

Configuration - electron-webpack
Defines the path to a process's or common usage directory, relative to the project's root directory. renderer.sourceDirectory can be null if you don't...
Read more >
webpack - How do I set an Electron variable at compile time?
The idea is to expose a variable via webpack.DefinePlugin and you can do this for both your main and renderer processes. With electron-webpack...
Read more >
NODE_ENV in webpack.renderer.additions.js #105 - GitHub
I'd like to use process.env.NODE_ENV in the webpack.renderer.additions.js file I specify in the "electronWebpack" part of my package.json, ...
Read more >
Target | webpack
Compile for Electron for renderer process, providing a target using NodeTemplatePlugin with asyncChunkLoading set to true , FunctionModulePlugin for browser ...
Read more >
Creating a React-based Electron application with ... - Medium
The electron-webpack project provides HMR support through Webpack and ... Now when you change the renderer source code, renderer.js will be ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found