@farmfe/js-plugin-svgr
Support React SVG Components
for Farm.
Installationâ
- npm
- yarn
- pnpm
npm install @farmfe/js-plugin-svgr
yarn add @farmfe/js-plugin-svgr
pnpm add @farmfe/js-plugin-svgr
Usageâ
import { UserConfig } from '@farmfe/core';
import farmJsPluginSvgr from '@farmfe/js-plugin-svgr';
const config: UserConfig = {
plugins: [
farmJsPluginSvgr({ /* options */ })
]
}
Optionsâ
export interface FarmSvgrPluginOptions {
svgrOptions?: SvgrOptions;
filters?: {
resolvedPaths?: string[];
};
}
svgrOptionsâ
See svgr options for more details.
Example:
import path from 'node:path';
import { UserConfig } from '@farmfe/core';
import farmJsPluginSvgr from '@farmfe/js-plugin-svgr';
const config: UserConfig = {
plugins: [
farmJsPluginSvgr({
svgrOptions: {
loadPaths: [path.resolve(process.cwd(), 'styles')]
}
})
]
}
export default config;
filtersâ
Which files should be processed by svgr
. Default to { resolvedPaths: ['\\.svg$'] }
.
resolvedPaths
: Only files under these paths will be processed. Support regex.
Example:
import { UserConfig } from '@farmfe/core';
import farmJsPluginSvgr from '@farmfe/js-plugin-svgr';
const config: UserConfig = {
plugins: [
farmJsPluginSvgr({
filters: {
// all files end with .custom-svg will be processed
resolvedPaths: ['\\.custom-svg$'],
}
})
]
}
export default config;