Skip to content

Commit

Permalink
'feature/epmgcip-162/next-migration' (#28)
Browse files Browse the repository at this point in the history
Co-authored-by: Siarhei Balonikau <[email protected]>
  • Loading branch information
gordoney and Siarhei Balonikau authored Oct 1, 2024
1 parent 4cbfdd0 commit 87171be
Show file tree
Hide file tree
Showing 31 changed files with 1,794 additions and 398 deletions.
16 changes: 15 additions & 1 deletion jest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -204,4 +204,18 @@ const config: Config = {
// watchman: true,
};

export default createJestConfig(config);
const jestConfigWithOverrides = async () => {
const configFn = createJestConfig(config);
const res = await configFn();

res.moduleNameMapper = {
// We cannot depend on the exact key used by Next.js
// so we inject an SVG key higher up on the mapping tree
"\\.svg": "<rootDir>/src/mocks/svgrMock.ts",
...res.moduleNameMapper,
};

return res;
};

export default jestConfigWithOverrides;
39 changes: 38 additions & 1 deletion next.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,43 @@ import createNextIntlPlugin from 'next-intl/plugin';
const withNextIntl = createNextIntlPlugin();

/** @type {import('next').NextConfig} */
const nextConfig = {};
const nextConfig = {
webpack: (config) => {
const fileLoaderRule = config.module.rules.find((rule) =>
rule.test?.test?.('.svg'),
)

config.module.rules.push(
{
...fileLoaderRule,
test: /\.svg$/i,
resourceQuery: /url/,
},
{
test: /\.svg$/i,
issuer: fileLoaderRule.issuer,
resourceQuery: { not: [...fileLoaderRule.resourceQuery.not, /url/] },
use: ['@svgr/webpack'],
},
)

fileLoaderRule.exclude = /\.svg$/i

return config
},
images: {
remotePatterns: [{
protocol: 'https',
hostname: 'images.ctfassets.net',
port: '',
pathname: '**/**'
}]
},
logging: {
fetches: {
fullUrl: true,
},
},
};

export default withNextIntl(nextConfig);
Loading

0 comments on commit 87171be

Please sign in to comment.