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

Refactor webpack to accept svg imports #81

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

caiulucas
Copy link

@caiulucas caiulucas commented Mar 24, 2022

The problem:

I found out that the svg imports was not working:

Screenshot_20220324_111518

Screenshot_20220324_111654

The solution

What I did was change the rules.webpack.js file adding in file-loader plugin another file type (svg):

 {
    test: /\.(png|jpe?g|gif|svg)$/i,
    loader: 'file-loader',
    options: {
      name: '[path][name].[ext]',
    },
  }

Then, in src/@types/image.d.ts I added a new declaration:

declare module '*.png';
declare module '*.jpeg';
declare module '*.jpg';
declare module '*.gif';

// New declaration
declare module '*.svg';

And now we can import svg files directly in code :)

@caiulucas caiulucas mentioned this pull request Mar 24, 2022
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