Skip to content

Commit

Permalink
ignore query params when checking the filename
Browse files Browse the repository at this point in the history
  • Loading branch information
drslump committed Aug 7, 2021
1 parent 5ab5562 commit e1f25c7
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
9 changes: 5 additions & 4 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,14 @@ export function createSvgPlugin(
return {
name: "vite-plugin-vue2-svg",
async transform(_source: string, id: string) {
const isMatch = id.match(svgRegex);
const fname = id.replace(/\?.*$/, "");
const isMatch = svgRegex.test(fname);
if (isMatch) {
const code: string = readFileSync(id, { encoding: "utf-8" });
const svg = await optimizeSvg(svgo, code, id);
const code: string = readFileSync(fname, { encoding: "utf-8" });
const svg = await optimizeSvg(svgo, code, fname);
if (!svg)
throw new Error(`[vite-plugin-vue2-svg] fail to compile ${id}`);
const result = compileSvg(svg, id);
const result = compileSvg(svg, fname);

return result;
}
Expand Down
2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"removeComments": true,
"sourceMap": true,
"downlevelIteration": true,
"lib": ["es6"],
"lib": ["es6", "dom"],
"outDir": "./lib",
"declaration": true
},
Expand Down

0 comments on commit e1f25c7

Please sign in to comment.