diff --git a/packages/hap-toolkit/src/gen-webpack-conf/index.js b/packages/hap-toolkit/src/gen-webpack-conf/index.js index d65e021d..ac395541 100644 --- a/packages/hap-toolkit/src/gen-webpack-conf/index.js +++ b/packages/hap-toolkit/src/gen-webpack-conf/index.js @@ -211,7 +211,19 @@ export default async function genWebpackConf(launchOptions, mode) { globalObject: 'window', path: BUILD_DIR, filename: '[name].js', - publicPath: '/' + publicPath: '/', + devtoolModuleFilenameTemplate: (info) => { + let resPath = info.resourcePath + let namespace = info.namespace + // ide打包分情况生成的路径不对 "E:\\work\\ide-new\\.build\\electron\\D:\\Users\\Desktop\\1_quickapp-code-21\\src\\app.ux",需要换成'.src/app.ux' + if (resPath.indexOf('electron') !== -1) { + // 拿到src及以后的并将\\换成/ + const src = resPath.split(namespace)[1].replace(/\\/g, '/') + return `webpack://${namespace}/${resPath.replace(resPath, '.' + src)}` + } + // 默认返回 + return `webpack://${namespace}/${resPath}?${info.hash}` + } }, module: { rules: [