Skip to content

Commit

Permalink
feat: add support for svgr
Browse files Browse the repository at this point in the history
no type caveat on the svg jsx
  • Loading branch information
SuperSuperDev authored and theodorusclarence committed Jan 7, 2022
1 parent c3247a3 commit 52515fe
Show file tree
Hide file tree
Showing 5 changed files with 1,307 additions and 8 deletions.
19 changes: 19 additions & 0 deletions next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,23 @@ module.exports = {
// 'res.cloudinary.com',
// ],
// },

// SVGR
webpack(config) {
config.module.rules.push({
test: /\.svg$/i,
issuer: /\.[jt]sx?$/,
use: [
{
loader: '@svgr/webpack',
options: {
typescript: true,
icon: true,
},
},
],
});

return config;
},
};
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
"devDependencies": {
"@commitlint/cli": "^13.2.1",
"@commitlint/config-conventional": "^13.2.0",
"@svgr/webpack": "^6.1.2",
"@tailwindcss/forms": "^0.4.0",
"@testing-library/jest-dom": "^5.16.1",
"@testing-library/react": "^12.1.2",
Expand Down
1 change: 1 addition & 0 deletions public/svg/Vercel.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
14 changes: 13 additions & 1 deletion src/pages/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,15 @@ import UnderlineLink from '@/components/links/UnderlineLink';
import UnstyledLink from '@/components/links/UnstyledLink';
import Seo from '@/components/Seo';

/**
* SVGR Support
* Caveat: No React Props Type.
*
* You can override the next-env if the type is important to you
* @see https://stackoverflow.com/questions/68103844/how-to-override-next-js-svg-module-declaration
*/
import Vercel from '~/svg/Vercel.svg';

// !STARTERCONF -> Select !STARTERCONF and CMD + SHIFT + F
// Before you begin editing, follow all comments with `STARTERCONF`,
// to customize the default configuration.
Expand All @@ -20,7 +29,10 @@ export default function HomePage() {
<main>
<section className='bg-white'>
<div className='layout flex flex-col justify-center items-center min-h-screen text-center'>
<h1>Next.js + Tailwind CSS + TypeScript Starter</h1>
<Vercel className='text-5xl' />
<h1 className='mt-4'>
Next.js + Tailwind CSS + TypeScript Starter
</h1>
<p className='mt-2 text-sm text-gray-800'>
A starter for Next.js, Tailwind CSS, and TypeScript with Absolute
Import, Seo, Link component, pre-configured with Husky{' '}
Expand Down
Loading

0 comments on commit 52515fe

Please sign in to comment.