'In the electron project, how should I configure webpack to correctly guide electron to find the js.map file?

enter image description here

Webpack-serve is used in the project, and the listening port is 9000, which leads to the path error of sourcemap, and finally causes electron to print a lot of HTTP request errors in the console.

This is driving me crazy, how do I configure webpack to properly direct electron to find the js.map file?

Here is my current configuration related to sourcemap:

webpack.config.js:

module.exports = {
    mode: "development",
    devtool: "inline-source-map",
    devServer: {
        static: {
        directory: path.join(__dirname, '../public'),
    },
    port: 9000,
    }
    ...
}

Webpack version: ^5.69.0

Webpack-cli version: ^4.9.2

webpack-dev-server version: ^4.7.4



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source