fix(electron): sourcemap not loading for electron dev mode (#9951)

This commit is contained in:
pengx17
2025-02-05 08:34:57 +00:00
parent ee0cfe4dc7
commit a1beb2aadb
2 changed files with 15 additions and 24 deletions

View File

@@ -432,6 +432,21 @@ export function createWebpackConfig(
if (buildConfig.isElectron) {
config.plugins.push(createShellHTMLPlugin(flags, buildConfig));
config.plugins.push(createBackgroundWorkerHTMLPlugin(flags, buildConfig));
// sourcemap url like # sourceMappingURL=76-6370cd185962bc89.js.map wont load in electron
// this is because the default file:// protocol will be ignored by Chromium
// so we need to replace the sourceMappingURL to assets:// protocol
// for example:
// replace # sourceMappingURL=76-6370cd185962bc89.js.map
// to # sourceMappingURL=assets://./{dir}/76-6370cd185962bc89.js.map
config.plugins.push(
new webpack.SourceMapDevToolPlugin({
append: pathData => {
return `\n//# sourceMappingURL=assets://./${pathData.filename}.map`;
},
filename: '[file].map',
})
);
}
return config;