Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

300
Views
How to include a .js file into html page with webpack and electron-forge?

How to include a .js file into html page with webpack and electron-forge?

'html` page :

<html>
  <head>
    <meta charset="UTF-8">
  </head>
  <body>

    <div id="app"></div>

    <div class='viewer' id='viewer' title="MainPage" width= "480" height="480">

    <script> const global = globalThis; </script>
    <script src="./file-to-import.js"></script>
    <script>
    </script>

    <style>
     </style>

  </body>
</html>

I've added an entry point in package.json :

           "entryPoints": [
            {
              "html": "./src/app/index.html",
              "js": "./src/app/renderer.ts",
              "preload": {
                "js": "./src/main/preload/preload.ts"
              },
              "name": "main_window"
            },
            {
              "html": "./src/app/index.html",
              "js": "./src/app/file-to-import.js",
              "preload": {
                "js": "./src/main/preload/preload.ts"
              },
              "name": "main_window"
            },

And I also added a copy-path to webpack.plugins.js :

new CopyPlugin({
    patterns: [
      {
        from: path.resolve(__dirname, "./src/app/file-to-import.js"),
        to: path.resolve(__dirname, ".webpack/renderer/main_window/file-to-import.js")
      }
    ]
  })

In .webpack/renderer/main_window the file file-to-import.js is present :

(base) raphy@pc:~/Playground/.webpack/renderer/main_window$ ls -lah
total 716K
drwxrwxr-x 2 raphy raphy 4.0K Jun 13 13:44 .
drwxrwxr-x 4 raphy raphy 4.0K Jun 13 13:44 ..
-rw-rw-r-- 1 raphy raphy   60 Jun 13 13:44 file-to-import.js
-rw-rw-r-- 1 raphy raphy  409 Jun 13 13:44 index.html
-rw-rw-r-- 1 raphy raphy 554K Jun 13 13:44 index.js
-rw-rw-r-- 1 raphy raphy 141K Jun 13 13:44 preload.js

but I still get failed to load resource : enter image description here

What am I doing wrongly? How to correctly load the file into the html page?

about 4 years ago · Santiago Gelvez
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!