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: MAIN_WINDOW_PRELOAD_WEBPACK_ENTRY is not defined

See original GitHub issue
  • I have read the contribution documentation for this project.
  • I agree to follow the code of conduct that this project follows, as appropriate.
  • I have searched the issue tracker for an issue that matches the one I want to file, without success.

Please describe your issue:

I’m using the repo provided by @tgds found here. While it is in typescript rather than JS, it works no problem using the MAIN_WINDOW_WEBPACK_ENTRY variable.

The documentation for the webpack plugin says

For an entry point with the name main_window two variables will be defined MAIN_WINDOW_WEBPACK_ENTRY and MAIN_WINDOW_PRELOAD_WEBPACK_ENTRY

with this example:

const mainWindow = new BrowserWindow({
  webPreferences: {
    preload: MAIN_WINDOW_PRELOAD_WEBPACK_ENTRY,
  }
});

mainWindow.loadUrl(MAIN_WINDOW_WEBPACK_ENTRY);

However, if I modify the code in the repo provided to match, I get an error:

ss 2019-02-06 at 01 33 56

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:14 (3 by maintainers)

github_iconTop GitHub Comments

33reactions
karlitoscommented, Aug 6, 2020

What worked for me was:

"entryPoints": [
                {
                  "html": "./src/index.html",
                  "js": "./src/renderer.tsx",
                  "name": "main_window",
                  "preload": {
                    "js": "./src/preload.ts"
                  }
                }
              ]

I found it by looking at the repository related to another reported bug. It would be truly appreciated if you could update the documentation a little bit - I was searching for hours to find a way how tu use typescript in the preload script.

8reactions
evil-shrikecommented, Dec 2, 2021

It only says that I should use the variable MAIN_WINDOW_PRELOAD_WEBPACK_ENTRY but says nothing where it comes from and what should I do to initialize it.

Also it’d be very helpful to explain the magic behind the naming.

Read more comments on GitHub >

github_iconTop Results From Across the Web

MAIN_WINDOW_PRELOAD_WE...
@G-Rath MAIN_WINDOW_PRELOAD_WEBPACK_ENTRY will only be defined if a preload is defined in your @electron-forge/plugin-webpack config. Their is ...
Read more >
WebPack-Dev-Server error: require is not defined
I hit this issue when a webpack.config.js from a node app for the base of a react app ...
Read more >
Webpack Plugin - Electron Forge
This plugin makes it easy to set up standard webpack tooling to compile both your main process code and your renderer process code,...
Read more >
Entry and Context - webpack
The entry object is where webpack looks to start building the bundle. The context is an absolute string to the directory that contains...
Read more >
Configuration Languages - webpack
Webpack accepts configuration files written in multiple programming and data languages. The list of supported file extensions can be found in the ...
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