添加一些数据
This commit is contained in:
@@ -23,23 +23,23 @@ import type { Plugin } from 'rollup';
|
||||
*
|
||||
* data URL 本身是绝对的,不需要 import.meta.url 作为 base,因此这种替换是安全的。
|
||||
*/
|
||||
const fixWebpack5CompatPlugin = (): Plugin => ({
|
||||
name: 'fix-webpack5-compat',
|
||||
renderChunk(code) {
|
||||
// 匹配 new URL("data:...", import.meta.url).href 或 new URL('data:...', import.meta.url).href
|
||||
const fixed = code.replace(
|
||||
/new URL\(["'](data:[^"']+)["'],\s*import\.meta\.url\)\.href/g,
|
||||
'"$1"'
|
||||
);
|
||||
if (fixed !== code) {
|
||||
console.log('[fix-webpack5-compat] Replaced new URL(data:..., import.meta.url) with direct data URL');
|
||||
}
|
||||
return {
|
||||
code: fixed,
|
||||
map: null,
|
||||
};
|
||||
},
|
||||
});
|
||||
// const fixWebpack5CompatPlugin = (): Plugin => ({
|
||||
// name: 'fix-webpack5-compat',
|
||||
// renderChunk(code) {
|
||||
// // 匹配 new URL("data:...", import.meta.url).href 或 new URL('data:...', import.meta.url).href
|
||||
// const fixed = code.replace(
|
||||
// /new URL\(["'](data:[^"']+)["'],\s*import\.meta\.url\)\.href/g,
|
||||
// '"$1"'
|
||||
// );
|
||||
// if (fixed !== code) {
|
||||
// console.log('[fix-webpack5-compat] Replaced new URL(data:..., import.meta.url) with direct data URL');
|
||||
// }
|
||||
// return {
|
||||
// code: fixed,
|
||||
// map: null,
|
||||
// };
|
||||
// },
|
||||
// });
|
||||
|
||||
export default defineConfig(() => {
|
||||
return {
|
||||
@@ -81,9 +81,9 @@ export default defineConfig(() => {
|
||||
// 禁用代码分割,将所有代码打包到一个文件
|
||||
inlineDynamicImports: true,
|
||||
},
|
||||
plugins: [
|
||||
fixWebpack5CompatPlugin(),
|
||||
],
|
||||
// plugins: [
|
||||
// fixWebpack5CompatPlugin(),
|
||||
// ],
|
||||
},
|
||||
sourcemap: true,
|
||||
emptyOutDir: true,
|
||||
|
||||
Reference in New Issue
Block a user