Configuration Files
SVGR supports project configuration files for SVGR, SVGO and Prettier.
SVGR
SVGR uses cosmiconfig for configuration file support. This means you can configure SVGR via:
- A
.svgrrcfile, written in YAML or JSON, with optional extensions: .yaml/.yml/.json/.js. - A
svgr.config.jsfile that exports an object. - A "svgr" key in your package.json file.
The configuration file will be resolved starting from the location of the file being formatted, and searching up the file tree until a config file is (or isn't) found.
The options to the configuration file are the same as the API options.
Example
JSON:
{"icon": true,"expandProps": false}
JS:
// .svgrrc.jsmodule.exports = {icon: true,expandProps: false,}
YAML:
# .svgrrcicon: trueexpandProps: false
SVGO
The recommended way to configure SVGO for SVGR is to use svgo.config.js or svgo.config.cjs.
Even if it is not recommended, you can also use svgoConfig option to specify your SVGO configuration. svgoConfig has precedence on svgo.config.js.
Prettier
The recommended way to configure Prettier for SVGR is to use .prettierrc. It is fully supported in all formats available and it is relative to the transformed SVG file.
Even if it is not recommended, you can also use prettierConfig option to specify your Prettier configuration. prettierConfig has precedence on .prettierrc.