From 4d2276b323f3bb263397fb2e0b027f50b8b5e5a2 Mon Sep 17 00:00:00 2001 From: Alexander Bentkamp Date: Tue, 25 Jun 2024 19:45:54 +0200 Subject: [PATCH] Fix regex to match on .js but not on .json --- src/esbuildImportMetaUrlPlugin.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/esbuildImportMetaUrlPlugin.ts b/src/esbuildImportMetaUrlPlugin.ts index a2d78b5..c417d1e 100644 --- a/src/esbuildImportMetaUrlPlugin.ts +++ b/src/esbuildImportMetaUrlPlugin.ts @@ -7,7 +7,7 @@ export default { name: 'import.meta.url', setup ({ onLoad }) { // Help vite that bundles/move files in dev mode without touching `import.meta.url` which breaks asset urls - onLoad({ filter: /.*\.js/, namespace: 'file' }, async args => { + onLoad({ filter: /.*\.js$/, namespace: 'file' }, async args => { const code = fs.readFileSync(args.path, 'utf8') const assetImportMetaUrlRE = /\bnew\s+URL\s*\(\s*('[^']+'|"[^"]+"|`[^`]+`)\s*,\s*import\.meta\.url\s*(?:,\s*)?\)/g