feat: Улучшена работа с svg, добавлена поддержка кастомизации
This commit is contained in:
@@ -17,7 +17,32 @@
|
|||||||
export function buildSvgrLoader() {
|
export function buildSvgrLoader() {
|
||||||
const svgrLoader = {
|
const svgrLoader = {
|
||||||
test: /\.svg$/,
|
test: /\.svg$/,
|
||||||
use: ['@svgr/webpack'],
|
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
|
return svgrLoader
|
||||||
|
|||||||
6
src/app/types/declarations.d.ts
vendored
6
src/app/types/declarations.d.ts
vendored
@@ -11,4 +11,8 @@ declare module '*.scss' {
|
|||||||
declare module '*.png'
|
declare module '*.png'
|
||||||
declare module '*.jpg'
|
declare module '*.jpg'
|
||||||
declare module '*.jpeg'
|
declare module '*.jpeg'
|
||||||
declare module '*.svg'
|
declare module '*.svg' {
|
||||||
|
import React from 'react'
|
||||||
|
const SVGComponent: React.FC<React.SVGProps<SVGSVGElement>>
|
||||||
|
export default SVGComponent
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user