svgo-loader

4.0.0 • Public • Published

svgo loader for webpack

Install

$ npm install svgo-loader --save-dev

... or with Yarn

$ yarn add svgo-loader -D

Usage

Documentation: Using loaders

module.exports = {
  ...,
  module: {
    rules: [
      {
        test: /\.svg$/,
        type: 'asset',
        loader: 'svgo-loader'
      }
    ]
  }
}

By default svgo-loader uses config from svgo.config.js similar to svgo cli. See how to configure svgo.

Specify configFile option to load custom config module:

module.exports = {
  ...,
  module: {
    rules: [
      {
        test: /\.svg$/,
        type: 'asset',
        loader: 'svgo-loader',
        options: {
          configFile: './scripts/svgo.config.js'
        }
      }
    ]
  }
}

or to disable loading config:

module.exports = {
  ...,
  module: {
    rules: [
      {
        test: /\.svg$/,
        type: 'asset',
        loader: 'svgo-loader',
        options: {
          configFile: false
        }
      }
    ]
  }
}

You can also specify options which override loaded from config

module.exports = {
  ...,
  module: {
    rules: [
      {
        test: /\.svg$/,
        type: 'asset',
        loader: 'svgo-loader',
        options: {
          multipass: true,
          js2svg: {
            indent: 2,
            pretty: true,
          }
        }
      }
    ]
  }
}

License and Copyright

This software is released under the terms of the MIT license.

Readme

Keywords

Package Sidebar

Install

npm i svgo-loader

Weekly Downloads

252,454

Version

4.0.0

License

MIT

Unpacked Size

34 kB

Total Files

17

Last publish

Collaborators

  • pozadi
  • trysound