Skip to content

Commit

Permalink
fix svg import on build
Browse files Browse the repository at this point in the history
  • Loading branch information
arzafran committed Jan 7, 2025
1 parent bfc74a8 commit a066437
Show file tree
Hide file tree
Showing 3 changed files with 228 additions and 182 deletions.
61 changes: 61 additions & 0 deletions next.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,67 @@ const nextConfig: NextConfig = {
],
formats: ['image/avif', 'image/webp'],
},
webpack: (config) => {
const fileLoaderRule = config.module.rules.find(
(rule: { test?: { test?: (path: string) => boolean } }) =>
rule.test?.test?.('.svg')
)
if (fileLoaderRule) {
fileLoaderRule.exclude = /\.svg$/
}

config.module.rules.push({
test: /\.svg$/,
use: [
{
loader: '@svgr/webpack',
options: {
memo: true,
dimensions: false,
svgoConfig: {
multipass: true,
plugins: [
'removeDimensions',
'removeOffCanvasPaths',
'reusePaths',
'removeElementsByAttr',
'removeStyleElement',
'removeScriptElement',
'prefixIds',
'cleanupIds',
{
name: 'cleanupNumericValues',
params: {
floatPrecision: 1,
},
},
{
name: 'convertPathData',
params: {
floatPrecision: 1,
},
},
{
name: 'convertTransform',
params: {
floatPrecision: 1,
},
},
{
name: 'cleanupListOfValues',
params: {
floatPrecision: 1,
},
},
],
},
},
},
],
})

return config
},
headers: async () => [
{
source: '/(.*)',
Expand Down
56 changes: 28 additions & 28 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,61 +19,61 @@
"@darkroom.engineering/hamo": "0.6.46",
"@hubspot/api-client": "^12.0.1",
"@next/third-parties": "^15.1.3",
"@react-three/drei": "^9.115.0",
"@react-three/drei": "^9.120.5",
"@react-three/fiber": "9.0.0-rc.0",
"@storyblok/js": "^3.1.7",
"@storyblok/js": "^3.2.1",
"@theatre/core": "^0.7.2",
"@theatre/studio": "^0.7.2",
"babel-plugin-react-compiler": "19.0.0-beta-a7bf2bd-20241110",
"clsx": "^2.1.1",
"gsap": "^3.12.5",
"lenis": "1.1.19-dev.3",
"next": "15.1.3",
"postprocessing": "^6.36.4",
"postprocessing": "^6.36.6",
"react": "19.0.0",
"react-aria": "^3.35.1",
"react-aria-components": "^1.4.1",
"react-aria": "^3.36.0",
"react-aria-components": "^1.5.0",
"react-dom": "19.0.0",
"react-use": "^17.5.1",
"react-use": "^17.6.0",
"stats-gl": "^3.6.0",
"storyblok-js-client": "^6.10.1",
"storyblok-js-client": "^6.10.6",
"storyblok-rich-text-react-renderer": "^2.9.2",
"tempus": "1.0.0-dev.9",
"three": "^0.171.0",
"tempus": "1.0.0-dev.10",
"three": "^0.172.0",
"tunnel-rat": "^0.1.2",
"zustand": "5.0.2"
"zustand": "5.0.3"
},
"devDependencies": {
"@biomejs/biome": "1.9.4",
"@builder.io/partytown": "^0.10.2",
"@chromatic-com/storybook": "3.2.2",
"@next/bundle-analyzer": "^15.0.3",
"@storybook/addon-essentials": "^8.4.2",
"@storybook/addon-interactions": "^8.4.2",
"@storybook/addon-links": "^8.4.2",
"@storybook/addon-onboarding": "^8.4.2",
"@storybook/blocks": "^8.4.2",
"@storybook/nextjs": "^8.4.2",
"@storybook/react": "^8.4.2",
"@storybook/test": "^8.4.2",
"@builder.io/partytown": "^0.10.3",
"@chromatic-com/storybook": "3.2.3",
"@next/bundle-analyzer": "^15.1.3",
"@storybook/addon-essentials": "^8.4.7",
"@storybook/addon-interactions": "^8.4.7",
"@storybook/addon-links": "^8.4.7",
"@storybook/addon-onboarding": "^8.4.7",
"@storybook/blocks": "^8.4.7",
"@storybook/nextjs": "^8.4.7",
"@storybook/react": "^8.4.7",
"@storybook/test": "^8.4.7",
"@svgr/webpack": "^8.1.0",
"@types/node": "^22.9.0",
"@types/react": "^18.3.12",
"@types/three": "^0.169.0",
"@types/node": "^22.10.5",
"@types/react": "^19.0.3",
"@types/three": "^0.172.0",
"cross-env": "^7.0.3",
"cssnano": "^7.0.6",
"lefthook": "^1.8.2",
"lefthook": "^1.10.1",
"postcss-combine-duplicated-selectors": "^10.0.3",
"postcss-extend": "^1.0.5",
"postcss-flexbugs-fixes": "^5.0.2",
"postcss-functions": "^4.0.2",
"postcss-import": "^16.1.0",
"postcss-include-media": "^1.1.1",
"postcss-nesting": "^13.0.1",
"postcss-preset-env": "^10.1.0",
"postcss-preset-env": "^10.1.3",
"postcss-sort-media-queries": "^5.2.0",
"storybook": "^8.4.2",
"typescript": "^5.6.3"
"storybook": "^8.4.7",
"typescript": "^5.7.2"
},
"pnpm": {
"overrides": {
Expand Down
Loading

1 comment on commit a066437

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚡️ Lighthouse report for the changes in this commit:

🟢 Performance: 99
🟢 Accessibility: 90
🟢 Best practices: 96
🟠 SEO: 63

Lighthouse ran on https://satus-4o7h5xxac-darkroom-engineering.vercel.app/

Please sign in to comment.