-
-
Notifications
You must be signed in to change notification settings - Fork 522
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
[v6] doesn't work with Webpack 5's DefinePlugin #2177
Comments
Electron Forge currently only uses webpack 4, not webpack 5... that's why the webpack 5 define plugin doesn't work. You'll need to use V4 Plugins and Loaders. |
@dopry Thanks for the reply! 🙂 I thought Electron Forge 6 had support for Webpack 5? We're currently successfully using Electron Forge 6 with Webpack 5. |
Do you have a demo repo of how you got that setup?maybe I was wrong |
As far as I can tell, https://github.com/electron-userland/electron-forge/blob/master/packages/plugin/webpack/package.json, still says webpack 4. It looks like upgrading to webpack 5 hasn't been done yet. |
@dopry Whoops... looks like you're right! However, we've been using Electron Forge v6 with Webpack 5 for a week or so, now, and it mostly works 🙂 A few things are broken, but so far we've been able to hack around them 😁 Would you like me to open a feature request for Webpack 5 support, or should I just leave this bug open? I don't have currently have permission from my company to contribute to open source projects, so I'm afraid I can't work on a PR, sorry. However, I'd be happy to post more information about how we're using which pieces of Electron Forge v6 with Webpack 5, if that'd be helpful 🙂 |
Ah, looks like there's already a PR open for this: #2164 |
Closing in favor of #2208 |
Is there a recipe how to make DefinePlugin with electron-forge? My renderer config is the following const webpack = require('webpack');
module.exports = {
devtool: 'source-map',
resolve: {
extensions: ['.ts', '.tsx', '.js'],
},
module: {
rules: require('./rules.js'),
},
// The code below is required to make Sentry works
// https://cesarvarela.com/blog/how-to-configure-sentry-with-electron-forge
externals: {
electron: 'commonjs electron',
},
plugins: [
new webpack.DefinePlugin({
FB_ENV: JSON.stringify(process.env.FB_ENV),
TEST: JSON.stringify('1'),
}),
],
}; But I cannot get access to env vars in renderer process. |
@Deliaz We're using it that way 🙂 var myConfig = {
test: 'testing'
};
module.exports = {
.....,
plugins: [
new DefinePlugin({
GLOBALS: JSON.stringify(myConfig)
}),
]
} I vaguely seem to remember that maybe |
Preflight Checklist
Issue Details
To Reproduce
I'm using electron-forge v6 with webpack v5.10.2. It looks like v6 doesn't like webpack 5's webpack.DefinePlugin.
My
webpack.renderer.config.js
looks like this:I then use
GLOBALS.BACKEND_URL
in one of my.js
files:And then when I run
yarn electron-forge start
, I get this error:Additional Information
The text was updated successfully, but these errors were encountered: