Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/svg/svgo-loader
svgo loader for webpack
https://github.com/svg/svgo-loader
Last synced: 5 days ago
JSON representation
svgo loader for webpack
- Host: GitHub
- URL: https://github.com/svg/svgo-loader
- Owner: svg
- License: mit
- Created: 2014-12-13T16:12:45.000Z (about 10 years ago)
- Default Branch: main
- Last Pushed: 2024-08-30T10:49:38.000Z (4 months ago)
- Last Synced: 2025-01-01T21:49:31.795Z (10 days ago)
- Language: JavaScript
- Homepage:
- Size: 515 KB
- Stars: 307
- Watchers: 5
- Forks: 34
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-rspack - svgo-loader
- awesome-list - svgo-loader
README
# [svgo](https://github.com/svg/svgo) loader for [webpack](https://github.com/webpack/webpack)
## Install
```
$ npm install svgo-loader --save-dev
```... or with Yarn
```
$ yarn add svgo-loader -D
```## Usage
[Documentation: Using loaders](https://webpack.js.org/concepts/loaders/#using-loaders)
```js
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](https://github.com/svg/svgo#configuration).Specify configFile option to load custom config module:
```js
module.exports = {
...,
module: {
rules: [
{
test: /\.svg$/,
type: 'asset',
loader: 'svgo-loader',
options: {
configFile: './scripts/svgo.config.js'
}
}
]
}
}
```or to disable loading config:
```js
module.exports = {
...,
module: {
rules: [
{
test: /\.svg$/,
type: 'asset',
loader: 'svgo-loader',
options: {
configFile: false
}
}
]
}
}
```You can also specify options which override loaded from config
```js
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](https://github.com/svg/svgo-loader/blob/master/LICENSE).