From 5259f1167908b4ddc193f22c90153287a7575d7f Mon Sep 17 00:00:00 2001 From: Krishan <33421343+kfiven@users.noreply.github.com> Date: Sun, 12 May 2024 14:17:41 +1000 Subject: [PATCH] Remove svg loader as available in Vite by default (#1728) --- package-lock.json | 10 ---------- package.json | 1 - vite.config.js | 2 -- viteSvgLoader.ts | 16 ---------------- 4 files changed, 29 deletions(-) delete mode 100644 viteSvgLoader.ts diff --git a/package-lock.json b/package-lock.json index f6583b0..d8bd758 100644 --- a/package-lock.json +++ b/package-lock.json @@ -88,7 +88,6 @@ "eslint-plugin-jsx-a11y": "6.6.1", "eslint-plugin-react": "7.31.11", "eslint-plugin-react-hooks": "4.6.0", - "mini-svg-data-uri": "1.4.4", "prettier": "2.8.1", "sass": "1.56.2", "typescript": "4.9.4", @@ -6643,15 +6642,6 @@ "url": "https://github.com/sponsors/sindresorhus" } }, - "node_modules/mini-svg-data-uri": { - "version": "1.4.4", - "resolved": "https://registry.npmjs.org/mini-svg-data-uri/-/mini-svg-data-uri-1.4.4.tgz", - "integrity": "sha512-r9deDe9p5FJUPZAk3A59wGH7Ii9YrjjWw0jmw/liSbHl2CHiyXj6FcDXDu2K3TjVAXqiJdaw3xxwlZZr9E6nHg==", - "dev": true, - "bin": { - "mini-svg-data-uri": "cli.js" - } - }, "node_modules/minimatch": { "version": "3.1.2", "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz", diff --git a/package.json b/package.json index 8c35e80..70dd6b5 100644 --- a/package.json +++ b/package.json @@ -98,7 +98,6 @@ "eslint-plugin-jsx-a11y": "6.6.1", "eslint-plugin-react": "7.31.11", "eslint-plugin-react-hooks": "4.6.0", - "mini-svg-data-uri": "1.4.4", "prettier": "2.8.1", "sass": "1.56.2", "typescript": "4.9.4", diff --git a/vite.config.js b/vite.config.js index e6ae956..f77abfc 100644 --- a/vite.config.js +++ b/vite.config.js @@ -6,7 +6,6 @@ import { vanillaExtractPlugin } from '@vanilla-extract/vite-plugin'; import { NodeGlobalsPolyfillPlugin } from '@esbuild-plugins/node-globals-polyfill'; import inject from '@rollup/plugin-inject'; import topLevelAwait from 'vite-plugin-top-level-await'; -import { svgLoader } from './viteSvgLoader'; import buildConfig from './build.config'; const copyFiles = { @@ -55,7 +54,6 @@ export default defineConfig({ }), viteStaticCopy(copyFiles), vanillaExtractPlugin(), - svgLoader(), wasm(), react(), ], diff --git a/viteSvgLoader.ts b/viteSvgLoader.ts deleted file mode 100644 index a119e3e..0000000 --- a/viteSvgLoader.ts +++ /dev/null @@ -1,16 +0,0 @@ -import svgToMiniDataURI from 'mini-svg-data-uri'; -import type { Plugin } from 'rollup'; -import fs from 'fs'; - -// TODO: remove this once https://github.com/vitejs/vite/pull/2909 gets merged -export const svgLoader = (): Plugin => ({ - name: 'vite-svg-patch-plugin', - transform: (code, id) => { - if (id.endsWith('.svg')) { - const extractedSvg = fs.readFileSync(id, 'utf8'); - const datauri = svgToMiniDataURI.toSrcset(extractedSvg); - return `export default "${datauri}"`; - } - return code; - }, -});