Giter Site home page Giter Site logo

Comments (6)

antfu avatar antfu commented on May 9, 2024

Can you provide more context?

from unplugin-icons.

xorik avatar xorik commented on May 9, 2024

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.

antfu avatar antfu commented on May 9, 2024

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.

xorik avatar xorik commented on May 9, 2024

@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.

antfu avatar antfu commented on May 9, 2024

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.

xorik avatar xorik commented on May 9, 2024

Thank you for the quick fix!

from unplugin-icons.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.