Skip to content

Commit

Permalink
feat: Ignore svg with '?raw' in path.
Browse files Browse the repository at this point in the history
  • Loading branch information
mige committed Jun 14, 2022
1 parent 1f435c5 commit 8017eb6
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,9 @@ function optimizeSvg(content: string, svgoConfig: OptimizeOptions) {
return result.data;
}

throw new Error(`Cannot optimize SVG ${svgoConfig.path}`);
throw new Error(
`[vite-plugin-vue2-svg] cannot optimize SVG ${svgoConfig.path}`,
);
}

export function createSvgPlugin(
Expand All @@ -53,6 +55,10 @@ export function createSvgPlugin(
return {
name: "vite-plugin-vue2-svg",
async transform(_source: string, id: string) {
if (/\?raw/.test(id)) {
return null;
}

const fname = id.replace(/\?.*$/, "");
const isMatch = svgRegex.test(fname);
if (isMatch) {
Expand Down

0 comments on commit 8017eb6

Please sign in to comment.