micro-app支持
micro-app微前端框架,在本地可以调试通,但是在打包的时候会报错
TypeError [ERR_INVALID_URL]: Invalid URL: /assets/
at new NodeError (node:internal/errors:329:5)
at onParseError (node:internal/url:537:9)
at new URL (node:internal/url:613:5)
at new URL (node:internal/url:610:22)
at /Users/jimei/work/algorithm-evaluation/vite.config.ts:706:40
at String.replace (
找到位置是因为在build/vite/index.ts中添加了:
vitePlugins.push(
(function () {
let basePath = '';
return {
name: 'hercules',
apply: 'build',
configResolved(config) {
basePath = `${config.base}${config.build.assetsDir}/`;
},
writeBundle(options, bundle) {
for (const chunkName in bundle) {
if (Object.prototype.hasOwnProperty.call(bundle, chunkName)) {
const chunk = bundle[chunkName];
if (chunk.fileName && chunk.fileName.endsWith('.js')) {
chunk.code = chunk.code.replace(/(from|import\()(\s*['"])(\.\.?\/)/g, (all, $1, $2, $3) => {
return all.replace($3, new URL($3, basePath))
})
const fullPath = join(options.dir, chunk.fileName)
writeFileSync(fullPath, chunk.code)
}
}
}
},
};
})() as any,
);
帮忙看一下这种是什么问题
可否提供一下重现代码或者最小化项目?
兄弟解决了吗?
兄弟解决了吗?
你们应用了吗
This issue is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 7 days