Giter VIP home page Giter VIP logo

Comments (7)

peter-mouland avatar peter-mouland commented on May 30, 2024 7

for me, this isn't a bug as the whole point of the loader is to enable 'inline' use i.e. within the html.

for previous project where some svg's were still used as background images, we created a separate loader config in webpack and a separate directory for the background svg's

e.g.

      { test: /\.svg$/,
        include: [/styles\/icons\/background-svgs/],
        loader: 'url-loader' },
      {
        test: /\.svg$/,
        exclude: [/styles\/icons\/background-svgs/],
        loader: 'svg-inline'
      }

from svg-inline-loader.

adrianmarinica avatar adrianmarinica commented on May 30, 2024 1

To make this work, I had to use a oneOf rule and path.resolve for the include and exclude rules, something like this:

{
    test: /\.svg$/,
    oneOf: [
        {
            exclude: path.resolve(__dirname, 'images/svg/css-icons/'),
            use: 'svg-inline-loader'
        },
        {
            include: path.resolve(__dirname, 'images/svg/css-icons/'),
            use: 'file-loader'
        },
    ],
},

from svg-inline-loader.

SathishGovindaraju avatar SathishGovindaraju commented on May 30, 2024

I can confirm this is not working for SVGs in stylesheets. Any updates on this?

from svg-inline-loader.

sairion avatar sairion commented on May 30, 2024

The transformation for data-format might be trivial, but I think it would be a bit hard to know if this (svg-inline) loader is being called from which loader. I assume you using css-loader?

from svg-inline-loader.

RadValentin avatar RadValentin commented on May 30, 2024

Yes, I'm using style-loader + css-loader. I figured that there might not be an easy solution for this. Would it be possible to check against a path or extension given as a param to the loader? And only apply the transformation for files that match?

from svg-inline-loader.

sairion avatar sairion commented on May 30, 2024

I tried looking into how css-loader works with this(svg-inline) loader and there is no way svg-inline can understand where the request is coming from. I though loader contexts would give some meta information but I could not find any (if there is anything, please someone let me know).

They also do not allow any queries for url(...) so unless someone fixes the css-loader (which I don't much want, they are tooo into css modules and all stuff) only way to fix this is, to have some kind of svg path convention and load it differently when a file follows the convention. I think it is pretty much like you mentioned above, @RadValentin.

While you are having trouble using css-loader + svg-inline I think you can try https://github.com/TrySound/postcss-inline-svg with some tweaked loader configurations. But I have seen a issue css-loader would break some result while using this postcss plugin, so I can't guarantee it works.

from svg-inline-loader.

perevezencev avatar perevezencev commented on May 30, 2024

I'm still experiencing this problem, nothing has changed by this point?

from svg-inline-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.