Giter Club home page Giter Club logo

Comments (7)

bhovhannes avatar bhovhannes commented on July 19, 2024

@iapYang you're doing everything correct.
If the most of your icons are referred from SCSS you should put noquotes: false in your webpack config.
But as you've correctly noticed that will break icons in case you are referring them from JS. In order to fix that you should explicitly pass noquotes option for each require from JS. That is, currently in your JS you're writing:

var icon = require('../../image/ignore/arrow.svg')

You should replace that by

var icon = require('!!svg-url-loader?noquotes!../../image/ignore/arrow.svg')

Let me know if this works for you.

from svg-url-loader.

iapYang avatar iapYang commented on July 19, 2024

@bhovhannes
Thanks a lot! This works really fine to me.
But in another case, If the most of my icons are referred from JS and I set noquotes: true, is there any way to render it correctly in scss in this case?

Thanks for the help!

from svg-url-loader.

bhovhannes avatar bhovhannes commented on July 19, 2024

You may use different extension for SVG images which you are referring from scss (something like .scss.svg). And in webpack config have separate test patterns - one for matching .svg without .scss prefix and another one for matching .scss.svg.

from svg-url-loader.

iapYang avatar iapYang commented on July 19, 2024

@bhovhannes
Appreciate your patience! Your answer helps me a lot!

from svg-url-loader.

bhovhannes avatar bhovhannes commented on July 19, 2024

@iapYang I am closing this, feel free to open another issue if any.

from svg-url-loader.

Mouvedia avatar Mouvedia commented on July 19, 2024

What about using issuer?

cf https://webpack.js.org/configuration/module/#rule-issuer

from svg-url-loader.

zcaceres avatar zcaceres commented on July 19, 2024

I used issuer:

{
              test: /\.svg$/,
              issuer: {
                include: /\.(css|scss)$/
              },
              use: [{
                loader: 'svg-url-loader',
                options: {}
              }]
}

from svg-url-loader.

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.