madzhup / svg-scaler-loader

Webpack svg scale loader

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

SVG Scaler Loader

Scale your svg files

Install

Install

yarn add style-loader --dev

or using npm

npm install style-loader --save-dev

It's recommended to combine svg-scaler-loader with the @svgr/webpack

component.js

import Icon from './icon.svg'

webpack.config.js

{
  module: {
    rules: [
      {
        test: /\.svg$/,
        use: [
          { loader: '@svgr/webpack' },
          {
            loader: 'svg-scaler-loader',
            options: {
              width: 24,
            }
          }
        ]
      }
    ]
  }
}

Options

width

type:number, will make the svg scale to the size by the number, will fix to square, unity all svg files to same size.

scale

type:number, just normal scale, but if have the width or the height option, the scale will not work.

About

Webpack svg scale loader

License:MIT License


Languages

Language:JavaScript 92.1%Language:Shell 7.9%