diff --git a/vite.config.js b/vite.config.js new file mode 100644 index 0000000..6981e36 --- /dev/null +++ b/vite.config.js @@ -0,0 +1,25 @@ +import fs from 'fs'; +import { defineConfig } from 'vite'; + +function inlineSvg(...paths) { + return { + name: 'inline-svg', + transformIndexHtml: { + enforce: 'pre', + transform: (html) => { + if (!Array.isArray(paths) || paths.length <= 0) return html; + + let newHtml = html; + paths.forEach((svg) => { + const extractedSvg = fs.readFileSync(svg, 'utf8'); + newHtml = newHtml.replace('', `${extractedSvg}`); + }); + return newHtml; + }, + }, + }; +} +export default defineConfig({ + server: { open: false }, + plugins: [inlineSvg('src/assets/icons.svg', '.ladle/assets/stories-icons.svg')], +});