Svgr: Ignore SVG for use within background image URL

Created on 7 Feb 2020  路  3Comments  路  Source: gregberge/svgr

Hi all,

Was wondering if there was a way to ignore certain svg's or directories to not be converted into React components so they can be used elsewhere such as the background image of a div inside a CSS file using

background-image: url('../../mySvg.svg');

Most helpful comment

Nevermind, it's clear now.

module: {
  rules: [
    { test: /\.(png|jpg|svg)$/i, issuer: /\.scss$/, use: "url-loader" },
    {
      test: /\.svg$/,
      exclude: /login/,
      issuer: /\.js$/,
      use: ["@svgr/webpack"],
    },
    {
      test: /\.scss$/i,
      use: ["style-loader", "css-loader", "sass-loader"],
    },
  ],
},

All 3 comments

I have the same issue and it's not yet clear how webpack can help here. Can you please provide an example usage?

Nevermind, it's clear now.

module: {
  rules: [
    { test: /\.(png|jpg|svg)$/i, issuer: /\.scss$/, use: "url-loader" },
    {
      test: /\.svg$/,
      exclude: /login/,
      issuer: /\.js$/,
      use: ["@svgr/webpack"],
    },
    {
      test: /\.scss$/i,
      use: ["style-loader", "css-loader", "sass-loader"],
    },
  ],
},
Was this page helpful?
0 / 5 - 0 ratings

Related issues

alamothe picture alamothe  路  6Comments

7ynk3r picture 7ynk3r  路  4Comments

liorgreenb picture liorgreenb  路  5Comments

chloesun picture chloesun  路  6Comments

kg-currenxie picture kg-currenxie  路  4Comments