Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 0 additions & 8 deletions gatsby-config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -145,14 +145,6 @@ export default {
path: './content/pages/404'
}
},
{
resolve: 'gatsby-plugin-react-svg',
options: {
rules: {
include: './src/images'
}
}
},
'gatsby-plugin-netlify'
]
};
4 changes: 3 additions & 1 deletion gatsby-node.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@ import { createSchemaCustomization } from './gatsby/createSchemaCustomization.mj
import { createPages } from './gatsby/createPages.mjs';
import { createResolvers } from './gatsby/createResolvers.mjs';
import { onCreateNode } from './gatsby/onCreateNode.mjs';
import { onCreateWebpackConfig } from './gatsby/onCreateWebpackConfig.mjs';

export {
createSchemaCustomization,
createPages,
createResolvers,
onCreateNode
onCreateNode,
onCreateWebpackConfig
};
55 changes: 55 additions & 0 deletions gatsby/onCreateWebpackConfig.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
import { createRequire } from 'node:module';

const require = createRequire(import.meta.url);

export const onCreateWebpackConfig = ({ actions, getConfig }) => {
const config = getConfig();

// Exclude SVGs from the default file loader
config.module.rules = config.module.rules.map((rule) => {
if (rule.test?.toString().includes('svg')) {
return { ...rule, exclude: /\.svg$/i };
}
return rule;
});

// Handle SVGs as either emitted asset URLs (`?url`) or React components
config.module.rules.push({
test: /\.svg$/i,
oneOf: [
{
resourceQuery: /url/,
type: 'asset/resource'
},
{
issuer: /\.[jt]sx?$/,
use: [
{
loader: require.resolve('@svgr/webpack'),
options: {
svgo: true,
svgoConfig: {
multipass: true,
plugins: [
{
name: 'preset-default',
params: {
overrides: {
removeViewBox: false,
inlineStyles: {
onlyMatchedOnce: false
}
}
}
}
]
}
}
}
]
}
]
});

actions.replaceWebpackConfig(config);
};
64 changes: 0 additions & 64 deletions node-scripts/minify-svgs.mjs

This file was deleted.

Loading
Loading