Files
gsap-carousel/config/build/loaders/buildSvgrLoader.ts

50 lines
1.3 KiB
TypeScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
/**
* Конфигурация SVGR loader для webpack
*
* Преобразует SVG файлы в React компоненты.
* Позволяет импортировать SVG как обычные React компоненты с возможностью
* управления их свойствами (цвет, размер и т.д.) через props.
*
* @returns {Object} Конфигурация @svgr/webpack loader
*
* @example
* import Logo from './logo.svg'
*
* function App() {
* return <Logo width={100} height={100} fill="red" />
* }
*/
export function buildSvgrLoader() {
const svgrLoader = {
test: /\.svg$/,
use: [
{
loader: '@svgr/webpack',
options: {
// Replace currentColor with props
replaceAttrValues: {
currentColor: '{props.stroke || "currentColor"}',
},
// Allow width and height to be customizable
dimensions: false,
svgoConfig: {
plugins: [
{
name: 'preset-default',
params: {
overrides: {
// Keep viewBox for proper scaling
removeViewBox: false,
},
},
},
],
},
},
},
],
}
return svgrLoader
}