Wondering what’s next for npm?Check out our public roadmap! »

    svgo-loader

    3.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$/,
            use: [
              {
                loader: 'file-loader'
              },
              {
                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$/,
            use: [
              {
                loader: 'file-loader'
              },
              {
                loader: 'svgo-loader',
                options: {
                  configFile: './scripts/svgo.config.js'
                }
              }
            ]
          }
        ]
      }
    }

    or to disable loading config:

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

    You can also specify options which override loaded from config

    module.exports = {
      ...,
      module: {
        rules: [
          {
            test: /\.svg$/,
            use: [
              {
                loader: 'file-loader'
              },
              {
                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.

    Keywords

    Install

    npm i svgo-loader

    DownloadsWeekly Downloads

    177,109

    Version

    3.0.0

    License

    MIT

    Unpacked Size

    24.8 kB

    Total Files

    14

    Last publish

    Collaborators

    • avatar
    • avatar