Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

301
Vistas
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
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda