Open bigbossx opened 1 year ago
额...没有进展吗,还是只有我有这个问题😂
求解决,我也是这个问题
写个webpack插件替换source map路径
const webpack = require('webpack')
class ReplaceSourceMappingURL {
apply(compiler) {
const regexp = /\/\/\# sourceMappingURL=(.*).js.map/;
const replaceStr = '//# sourceMappingURL=../$1.js.map';
compiler.hooks.thisCompilation.tap('ReplaceSourceMappingURL', (compilation) => {
compilation.hooks.processAssets.tap(
{
name: 'ReplaceSourceMappingURL',
stage: webpack.Compilation.PROCESS_ASSETS_STAGE_SUMMARIZE // see below for more stages
},
(assets) => {
for (const filename in assets) {
if (filename.endsWith('.js')) {
const source = assets[filename].source().replace(regexp, replaceStr);
assets[filename] = new webpack.sources.RawSource(source);
}
}
}
);
});
}
}
module.exports = {
configureWebpack: {
plugins: [new ReplaceSourceMappingURL()]
}
};
问题描述 sourcemapurl 生成的路径不对 应该是
而不是
复现步骤 [复现问题的步骤]
[或者可以直接贴源代码]
预期结果
实际结果
系统信息:
npm run info
的运行结果]补充信息 应该是webpack5 不太一样