Can't import SVG into Next.js

前端 未结 6 1696
隐瞒了意图╮
隐瞒了意图╮ 2020-12-09 07:39

When I try to import SVG Image then the following error shows. Which loader I have to use for importing SVG images?

./static/Rolling-1s-200px.svg 1:0
Module          


        
6条回答
  •  無奈伤痛
    2020-12-09 08:31

    This worked for me without any other dependency

    // In next.config.js
    
    const withSass = require('@zeit/next-sass');
    const withCSS = require("@zeit/next-css");
    
    module.exports = withCSS(withSass({
        webpack (config, options) {
            config.module.rules.push({
                test: /\.(png|jpg|gif|svg|eot|ttf|woff|woff2)$/,
                use: {
                    loader: 'url-loader',
                    options: {
                        limit: 100000
                    }
                }
            });
            return config;
        }
    }));
    

提交回复
热议问题