Comments (6)
Can you provide more context?
from unplugin-icons.
Sorry.
So I have a vue/vite app. Everything with latest versions. I search for icons on the website https://icones.js.org/. Then I add prefix i-
and replace comma to dash, so I get something like
<i-ic-twotone-directions-bus/>
Put it in template and it perfectly works.
But some icons e.g. mdi-light:alarm
or noto-v1:flag-for-flag-japan
don't work.
<!-- This doesn't work -->
<i-noto-v1-flag-for-flag-japan/>
Firefox gives this error in console:
Loading module from “http://localhost:3000/@id/@vite-icons/noto/v1-flag-for-flag-japan” was blocked because of a disallowed MIME type (“text/html”).
Chrome gives this:
App.vue:2 GET http://localhost:3000/@id/@vite-icons/noto/v1-flag-for-flag-japan net::ERR_ABORTED 404 (Not Found)
And after page reload web server doesn't show anything (white page).
I think this is because the noto-v1
contains a dash symbol, so parser gets confused.
So App.vue
:
<template>
<h3>Hello vite</h3>
<div id="icons">
<!-- This works -->
<i-ic-twotone-directions-bus/>
<!-- This doesn't work -->
<!-- <i-noto-v1-flag-for-flag-japan/>-->
</div>
</template>
<style>
#icons > * {
font-size: 100px;
padding: 10px;
}
</style>
vite.config.js
:
import Vue from '@vitejs/plugin-vue'
import Components from 'vite-plugin-components'
import ViteIcons, { ViteIconsResolver } from 'vite-plugin-icons'
export default {
plugins: [
Vue(),
Components({
customComponentResolvers: ViteIconsResolver(),
}),
ViteIcons(),
],
}
I hope it's clear now.
UPD: demo: https://github.com/xorik/vite-icons-demo just uncomment <i-noto-v1-flag-for-flag-japan/>
in App.vue
from unplugin-icons.
Ah, I see, it's indeed a bug. Could do that later, or if you would like to give a try, I am happy to see the PR. Thanks!
from unplugin-icons.
@antfu I'd like to help, but I have no idea how to debug plugins like that. Any suggestions how to start?
from unplugin-icons.
Actually, looks like all we need to do is to update the data source
https://github.com/antfu/vite-plugin-icons/blob/59a8ce431641ea211d654795fb1310771fe3dc18/src/resolver.ts#L36
I will do that now
from unplugin-icons.
Thank you for the quick fix!
from unplugin-icons.
Related Issues (20)
- Svelte 4 support HOT 5
- Unable to resolve path to module - Nextjs
- Global transform for every icon HOT 1
- SvelteKit Example Broken - Types HOT 3
- AutoInstall doesn't work on bun
- How to use icons in both .vue files and .jsx files?
- auto-import confused with mdi and mdi-light collection HOT 7
- Vue3/Vite auto importing icon names with sequential dashed numbers results in mangled filename HOT 15
- Latest version breaks with unplugin-vue-components HOT 12
- ID collisions in astro HOT 1
- `resolveId` doesn't work as expected when query params contains `.`s HOT 1
- components.d.ts path error if the name startswith prefix defined in collections HOT 6
- Vue 2 examples won't run
- Events don't fire in Vue 2 HOT 5
- How to use the icon's raw svg as url(data:....) in css? HOT 5
- How to auto import unplugin-icons ? HOT 1
- How to auto import icon set with plural names? HOT 7
- Symptom When the icon is imported automatically, an error message is displayed indicating that the icon version does not match
- Unable to use ?raw in SvelteKit HOT 3
- Hydration mismatch warning in vue >=3.4 (nuxt >=3.9) if an SVG uses `url(#id)` HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from unplugin-icons.