问题
Im a bit in the dark therefore reaching out as I couldnt find a solution or answer. Im using parcel with Vue and trying to import a static image as ../img/logo.svg
. This used to work before until I introduced Babel to the mix. Now I get Error: Cannot find module 'img/logo.svg'
during runtime. It is weird because in the dist folder I see a logo.svg with a hash. Is it a babel or parcel issue? do I need some extra plugin? or something Im missing?.
Im basically using babel out the box. I just have in my .babelrc
{
"presets": ["@babel/preset-env"]
}
The file structure goes like this, Im trying to reference logo.svg
from Page.vue
as import logo from '../img/logo.svg';
📦src
┣ 📂components
┃ ┣ 📜Component.vue
┣ 📂css
┃ ┗ css.css
┣ 📂img
┃ ┣ 📜logo.svg
┃
┣ 📂pages
┃ ┗ 📜Page.vue
┣ 📜index.html
┗ 📜main.js
.babelrc
Thank you so much in advance!
来源:https://stackoverflow.com/questions/63226633/parcel-babel-vue-error-cannot-find-module-img-svg