【问题标题】:How to migrate away from @zeit/next-sass deprecation?如何摆脱@zeit/next-sass 弃用?
【发布时间】:2021-05-06 21:18:04
【问题描述】:

如何迁移和更改 next.config.js 文件从 @zeit/next-sass 以使用 Next.js 对 Sass 的内置支持? https://www.npmjs.com/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;
    }
}));

【问题讨论】:

    标签: javascript webpack sass next.js


    【解决方案1】:

    Next.js 内置的 Sass 支持要求您安装 sass 作为依赖项。

    $ npm install sass
    

    然后,您可以简单地从您的配置中删除 @zeit/next-sass@zeit/next-css 插件。

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

    更多详情请查看official Sass support docs

    【讨论】:

      猜你喜欢
      • 2013-11-04
      • 2010-10-17
      • 2014-10-21
      • 2019-03-25
      • 2021-01-29
      • 1970-01-01
      • 2020-09-18
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多