Skip to content

Commit

Permalink
feat(package): add vite-plugin-svgr support for importing svg files a…
Browse files Browse the repository at this point in the history
…s react component
  • Loading branch information
mayurDayal2000 committed Dec 16, 2024
1 parent 23bb441 commit 8f0b924
Show file tree
Hide file tree
Showing 5 changed files with 316 additions and 9 deletions.
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@
"globals": "^15.12.0",
"typescript": "~5.6.2",
"typescript-eslint": "^8.15.0",
"vite": "^6.0.1"
"vite": "^6.0.1",
"vite-plugin-svgr": "^4.3.0"
},
"packageManager": "yarn@4.5.3"
}
4 changes: 2 additions & 2 deletions src/pages/HomePage.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import reactLogo from "@assets/react.svg";
import ReactLogo from "@assets/react.svg?react";

function HomePage() {
return (
<>
<h1>Welcome to My World!</h1>
<img src={reactLogo} className="logo react" alt="React logo" />
<ReactLogo className="logo react" />
</>
);
}
Expand Down
1 change: 1 addition & 0 deletions src/vite-env.d.ts
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
/// <reference types="vite/client" />
/// <reference types="vite-plugin-svgr/client" />
3 changes: 2 additions & 1 deletion vite.config.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import { defineConfig } from "vite";
import react from "@vitejs/plugin-react";
import { resolve } from "path";
import svgr from "vite-plugin-svgr";

export default defineConfig({
plugins: [react()],
plugins: [react(), svgr()],
resolve: {
alias: {
"@pages": resolve(__dirname, "src/pages"),
Expand Down
Loading

0 comments on commit 8f0b924

Please sign in to comment.