Provides in-line SVG support for Vite.
Inspired by vite-plugin-svg.
// vite.config.js
const reactSvgPlugin = require('vite-plugin-svg-react')
module.exports = {
plugins: [
reactSvgPlugin({
useSVGO: true // optimize svg by SVGO
})
]
}
import React from 'react';
import SkipIcon from '/@assets/skip_next-24px.svg';
const Component = (): JSX.Element => (
return (
<SkipIcon width={'4rem'} />
)
)
// react-app-env.d.ts
declare module '*.svg' {
import * as React from 'react';
export const ReactComponent: React.FunctionComponent<
React.SVGProps<SVGSVGElement> & { title?: string }
>;
export default ReactComponent;
}