Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

302
Visualizações
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 à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda