yellowspot / vite-plugin-raw-assets Goto Github PK
View Code? Open in Web Editor NEWVite plugin to load assets as strings.
Vite plugin to load assets as strings.
First of all, sorry if this is not really an issue but searching the web for hours already trying to find a solution, this is the only way left I feel...
Would be really appreciated if someone could at least point me to the right direction.
The issue:
TypeError: Failed to resolve module specifier '!raw-loader!../../assets/svg/icons/arrow-thin.svg'
I use a Vue3 (3.2.41)
application with Vite (3.1.8)
.
This app is consuming a 3rd party library (Vue2)
via node_modules
.
This library has an Icon component that is being imported by the Vue3 app and is just passing the icon name as a string:
// Vue3 app
import SvgIcon from '@code/icon-lib/src/components/Icon.vue';
...
<SvgIcon icon="arrow-thin" />
// Icon.vue of @code/icon-lib
...
methods: {
async getIcon() {
try {
const module = await import('!raw-loader!../../assets/svg/icons/' + this.icon + '.svg');
return module.default;
} catch (e) {
console.log(e)
console.warn(`Icon "${this.icon}" has not been found`);
return '';
}
},
}
...
I've already tried to use the following plugins, but without any success:
vite-svg-loader
vite-raw-plugin
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.