Giter VIP home page Giter VIP logo

vite-plugin-raw-assets's People

Contributors

dependabot[bot] avatar mgrunberg avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

vite-plugin-raw-assets's Issues

Is this something for my use case?

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

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.