4

I have an electron app where I use webpack and build with electron-forge (I think the problem comes from one of these two).

The issue appears when I build the app with electron-forge, no problem during the development process. When the app is built and I start it, no images are displayed and the debugging tool show me that the path it is trying to access is a wrong path.

I build like this:

"main": "./.webpack/main",
"scripts": {
  "make": "electron-forge make"
}

When the software is compiled path like this: resources/app/.webpack/renderer/login/images/logo.png

But the image is located here: resources/app/.webpack/renderer/images/logo.png

The login folder wrongly added to the path is there because in my package.json I have this configuration for electron-forge:

"plugins": [
  [
    "@electron-forge/plugin-webpack",
    {
      "mainConfig": "./webpack.main.config.js",
      "renderer": {
        "config": "./webpack.renderer.config.js",
        "entryPoints": [
          {
            "html": "./src/front/views/window.html",
            "js": "./src/front/scripts/login.ts",
            "name": "login",
            "preload": {
              "js": "./src/preload.ts"
            }
          },
          // other entrypoints
        ]
      }
    }
  ]
]

And we can see that the name of one entrypoint is "login" which is the first page of my app and which is the page the image is supposed to be on. But in development no login folder is created however when I build, login is added to the path of image that are supposed to be on the login page.

I have tried to install electron-webpack and do some changes to the webpack config files. For now, in the file webpack.renderer.config.js I have this:

const rules = require('./webpack.rules');

// other rules

rules.push({
  test: /\.(png|svg|jpg|gif)$/,
  include: [
    path.resolve(__dirname, "src/front/images"),
  ],
  use: {
    loader: 'file-loader',
    options: {
      name: '[name].[ext]',
      outputPath: 'images/'
    }
  }
});

module.export = {
  module: {
    rules
  }
  // other things
}
pl0xxxy
  • 53
  • 1
  • 7

0 Answers0