jpkleemans / vite-svg-loader

Vite plugin to load SVG files as Vue components
MIT License
555 stars 59 forks source link

[vite] Internal server error: Failed to resolve import "./banner.svg?component" #49

Closed jojowwbb closed 1 year ago

jojowwbb commented 2 years ago

"vite": "^2.9.2", "vite-svg-loader": "^3.2.0",

tsconfig.json { "compilerOptions": { "target": "esnext", "useDefineForClassFields": true, "module": "esnext", "moduleResolution": "node", "resolveJsonModule": true, "strict": true, "jsx": "preserve", "sourceMap": true, "isolatedModules": false, "esModuleInterop": true, "allowSyntheticDefaultImports": true, "typeRoots": [ "./@types" ], "lib": [ "esnext", "dom" ] }, "include": [ "@types/*.d.ts", "src/**/*.ts", "src/**/*.d.ts", "src/**/*.tsx", "src/**/*.vue" ], "references": [ { "path": "./tsconfig.node.json" } ] }

then,show the error:

下午11:07:21 [vite] Internal server error: Failed to resolve import "./banner.svg?component" from "src/pages/test/index.vue". Does the file exist? Plugin: vite:import-analysis File: /Users/glodon/workspace/glodon/mls-web/src/pages/test/index.vue 4 | import { ref } from "vue"; 5 | import { UploadFilled } from "@element-plus/icons-vue"; 6 | import IconComponent from "./banner.svg?component"; | ^ 7 | const _sfc_main = / @PURE / _defineComponent({ 8 | emits: ["onChange"],

the file 'banner.svg' had exists!

jpkleemans commented 2 years ago

Hi, does it work when omitting the ?component param?

jojowwbb commented 2 years ago

Hi, does it work when omitting the ?component param?

no!

jpkleemans commented 2 years ago

Could you share a Code Sandbox to reproduce the problem?

jpkleemans commented 1 year ago

Closed after 60 days of inactivity

Shr11 commented 1 year ago

did this error get sorted? I got the same for importing from assets folder & i'm completely new at this,Plz help

Screenshot_20230126_180611