Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add common Webpack Build Config for NextJS projects and Storybook for a shared SVGR integration. #37

Open
wants to merge 3 commits into
base: 2.x
Choose a base branch
from

Conversation

keichinger
Copy link
Contributor

No description provided.

@keichinger keichinger requested a review from apfelbox as a code owner May 24, 2024 06:59
@@ -1,4 +1,4 @@
exports.registerSvgWebpackLoader = (config) =>
export const registerSvgWebpackLoader = (config) =>
Copy link
Member

Choose a reason for hiding this comment

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

We should write it as TS now, so we don't need any new infrastructure.
Type-wise that might get hard, but using simplified types here is fine.

export const registerSvgWebpackLoader = (config) =>
{
// Grab the existing rule that handles SVG imports
const fileLoaderRule = config.module.rules.find((rule) => rule.test?.test?.(".svg") && rule.resourceQuery?.toString() !== "/raw/");
Copy link
Member

Choose a reason for hiding this comment

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

I don't remember the deal about the /raw/?

// Grab the existing rule that handles SVG imports
const fileLoaderRule = config.module.rules.find((rule) => rule.test?.test?.(".svg") && rule.resourceQuery?.toString() !== "/raw/");
// Modify the file loader rule to ignore *.svg, since we have it handled now.
fileLoaderRule.exclude = /\.svg$/i;
Copy link
Member

Choose a reason for hiding this comment

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

We should

  • add this exclude to every rule, not just the first we find (there might be multiple ones)
  • should merge the exclude with a maybe existing exclude
  • find out why we tested for /raw/ above

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants