最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - How to migrate away from @zeitnext-sass deprecation? - Stack Overflow

programmeradmin1浏览0评论

How can I migrate and change the next.config.js file from @zeit/next-sass to use Next.js built-in support for Sass? /@zeit/next-sass

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;
    }
}));

How can I migrate and change the next.config.js file from @zeit/next-sass to use Next.js built-in support for Sass? https://www.npmjs./package/@zeit/next-sass

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;
    }
}));
Share Improve this question edited Jan 15, 2022 at 11:12 juliomalves 50.6k23 gold badges178 silver badges169 bronze badges asked Feb 2, 2021 at 16:47 user1860739user1860739 711 silver badge3 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 4

Next.js built-in Sass support requires you to install sass as a dependency.

$ npm install sass

You can then simply remove @zeit/next-sass and @zeit/next-css plugins from your config.

// next.config.js
module.exports = {
    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;
    }
};

For further details check the official Sass support docs.

发布评论

评论列表(0)

  1. 暂无评论