Skip to main content
Version: 0.15

@farmfe/js-plugin-svgr

Support React SVG Components for Farm.

Installation​

npm install @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;
Extremely Fast Web Build Tool Written in Rust

Copyright Š 2024 Farm Community. Built with Docusaurus.