This Banner is For Sale !!
Get your ad here for a week in 20$ only and get upto 15k traffic Daily!!!

Next.js and – DEV Community


A fast share of my experiance with Subsequent.js and .svg information.

I wanted to show a bunch of .svg information on a Subsequent.js app.

Utilizing .svg information with Subsequent.js tremendous cool <Picture /> element is not recommended since it could possibly create sudden conduct and result in vulnerabilities if a safety coverage header shouldn’t be outlined.

So I wanted to include a loader.
The quickest approach I discovered was utilizing .babelrc file and babel-plugin-inline-react-svg.
It labored! properly sort of.. 😕 Some graphics weren’t displayed and a few did, whereas others have been reduce off unexpectedly.

I dug a bit extra and located this answer by @felixmosh on stackoverflow utilizing subsequent.config.js file.



TL;DR:

~ Step One:

$ npm set up --save-dev @svgr/webpack
Enter fullscreen mode

Exit fullscreen mode

~ Step Two:

// subsequent.config.js

module.exports = {
  webpack(config) {
    config.module.guidelines.push({
      check: /.svg$/,
      issuer: ts)x?$/,
       // for webpack 5 use
       // ts)x?$/] 
      ,

      use: ['@svgr/webpack'],
    });

    return config;
  },
};
Enter fullscreen mode

Exit fullscreen mode

When you used the above answer be sure that to provide the query and the reply a vote up on stackoverflow 🙂


Facet word, when you’re utilizing typescript in your undertaking and really feel unhealthy that the subsequent.config file is a .js file don’t as a result of subsequent doesn’t plan “to transpile subsequent.config.js.” As you’ll be able to see in this issue.

I hope it helped, thanks for studying!

The Article was Inspired from tech community site.
Contact us if this is inspired from your article and we will give you credit for it for serving the community.

This Banner is For Sale !!
Get your ad here for a week in 20$ only and get upto 10k Tech related traffic daily !!!

Leave a Reply

Your email address will not be published. Required fields are marked *

Want to Contribute to us or want to have 15k+ Audience read your Article ? Or Just want to make a strong Backlink?