Skip to content
Snippets Groups Projects
Commit e202102c authored by mateuszmiko's avatar mateuszmiko
Browse files

fix(svg config): use svg as image when add ?url to the path in the import

parent 0f507067
No related branches found
No related tags found
2 merge requests!223reset the pin numbers before search results are fetch (so the results will be...,!11fix(svg config): use svg as image when add ?url to the path in the import
...@@ -2,7 +2,7 @@ next.config.js ...@@ -2,7 +2,7 @@ next.config.js
tailwind.config.js tailwind.config.js
prettier.config.js prettier.config.js
postcss.config.js postcss.config.js
jest.config.mjs jest.config.ts
commitlint.config.js commitlint.config.js
.gitignore .gitignore
next-env.d.ts next-env.d.ts
...@@ -15,6 +15,11 @@ declare module '*.svg' { ...@@ -15,6 +15,11 @@ declare module '*.svg' {
export default content; export default content;
} }
declare module '*.svg?url' {
const content: any;
export default content;
}
declare module '*.jpg' { declare module '*.jpg' {
const content: StaticImageData; const content: StaticImageData;
export default content; export default content;
......
...@@ -23,6 +23,9 @@ const config = { ...@@ -23,6 +23,9 @@ const config = {
'!<rootDir>/src/**/*.d.ts', '!<rootDir>/src/**/*.d.ts',
'!**/node_modules/**', '!**/node_modules/**',
], ],
moduleNameMapper: {
'\\.svg': '@svgr/webpack',
},
coverageReporters: ['html', 'text', 'text-summary', 'cobertura'], coverageReporters: ['html', 'text', 'text-summary', 'cobertura'],
setupFilesAfterEnv: ['<rootDir>/setupTests.ts'], setupFilesAfterEnv: ['<rootDir>/setupTests.ts'],
}; };
......
...@@ -2,11 +2,21 @@ ...@@ -2,11 +2,21 @@
const nextConfig = { const nextConfig = {
reactStrictMode: true, reactStrictMode: true,
webpack(config) { webpack(config) {
config.module.rules.push({ const fileLoaderRule = config.module.rules.find(rule => rule.test?.test?.('.svg'));
test: /\.svg$/i, config.module.rules.push(
issuer: /\.[jt]sx?$/, {
use: ['@svgr/webpack'], ...fileLoaderRule,
}); test: /\.svg$/i,
resourceQuery: /url/,
},
{
test: /\.svg$/i,
issuer: /\.[jt]sx?$/,
resourceQuery: { not: /url/ },
use: ['@svgr/webpack'],
},
);
fileLoaderRule.exclude = /\.svg$/i;
return config; return config;
}, },
......
...@@ -20,8 +20,7 @@ ...@@ -20,8 +20,7 @@
"react": "18.2.0", "react": "18.2.0",
"react-dom": "18.2.0", "react-dom": "18.2.0",
"tailwind-merge": "^1.14.0", "tailwind-merge": "^1.14.0",
"tailwindcss": "3.3.3", "tailwindcss": "3.3.3"
"tailwindcss-animate": "^1.0.7"
}, },
"devDependencies": { "devDependencies": {
"@commitlint/cli": "^17.7.1", "@commitlint/cli": "^17.7.1",
...@@ -48,6 +47,7 @@ ...@@ -48,6 +47,7 @@
"jest": "^29.7.0", "jest": "^29.7.0",
"jest-environment-jsdom": "^29.7.0", "jest-environment-jsdom": "^29.7.0",
"jest-junit": "^16.0.0", "jest-junit": "^16.0.0",
"jest-svg-transformer": "^1.0.0",
"lint-staged": "^14.0.1", "lint-staged": "^14.0.1",
"prettier": "^3.0.3", "prettier": "^3.0.3",
"typescript": "^5.2.2" "typescript": "^5.2.2"
...@@ -10479,6 +10479,16 @@ ...@@ -10479,6 +10479,16 @@
"integrity": "sha512-xWGDIW6x921xtzPkhiULtthJHoJvBbF3q26fzloPCK0hsvxtPVelvftw3zjbHWSkR2km9Z+4uxbDDK/6Zw9B8w==", "integrity": "sha512-xWGDIW6x921xtzPkhiULtthJHoJvBbF3q26fzloPCK0hsvxtPVelvftw3zjbHWSkR2km9Z+4uxbDDK/6Zw9B8w==",
"dev": true "dev": true
}, },
"node_modules/jest-svg-transformer": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/jest-svg-transformer/-/jest-svg-transformer-1.0.0.tgz",
"integrity": "sha512-+kD21VthJFHIbI3DZRz+jo4sBOSR1qWEMXhVC28owRMqC5nA+zEiJrHOlj+EqQIztYMouRc1dIjE8SJfFPJUXA==",
"dev": true,
"peerDependencies": {
"jest": ">22",
"react": ">=16"
}
},
"node_modules/jest-util": { "node_modules/jest-util": {
"version": "29.7.0", "version": "29.7.0",
"resolved": "https://registry.npmjs.org/jest-util/-/jest-util-29.7.0.tgz", "resolved": "https://registry.npmjs.org/jest-util/-/jest-util-29.7.0.tgz",
...@@ -13685,14 +13695,6 @@ ...@@ -13685,14 +13695,6 @@
"node": ">=14.0.0" "node": ">=14.0.0"
} }
}, },
"node_modules/tailwindcss-animate": {
"version": "1.0.7",
"resolved": "https://registry.npmjs.org/tailwindcss-animate/-/tailwindcss-animate-1.0.7.tgz",
"integrity": "sha512-bl6mpH3T7I3UFxuvDEXLxy/VuFxBk5bbzplh7tXI68mwMokNYd1t9qPBHlnyTwfa4JGC4zP516I1hYYtQ/vspA==",
"peerDependencies": {
"tailwindcss": ">=3.0.0 || insiders"
}
},
"node_modules/tapable": { "node_modules/tapable": {
"version": "2.2.1", "version": "2.2.1",
"resolved": "https://registry.npmjs.org/tapable/-/tapable-2.2.1.tgz", "resolved": "https://registry.npmjs.org/tapable/-/tapable-2.2.1.tgz",
......
import Image from 'next/image'; import Image from 'next/image';
import { ChangeEvent, useState } from 'react'; import { ChangeEvent, useState } from 'react';
import lensIcon from '@/assets/vectors/icons/lens.svg'; import lensIcon from '@/assets/vectors/icons/lens.svg?url';
export const SearchBar = (): JSX.Element => { export const SearchBar = (): JSX.Element => {
const [searchValue, setSearchValue] = useState<string>(''); const [searchValue, setSearchValue] = useState<string>('');
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment