【问题标题】:The implementation option must be passed to the Sass task实现选项必须传递给 Sass 任务
【发布时间】:2019-01-21 19:03:13
【问题描述】:

运行 grunt - 我收到此错误消息:

Running "sass:all" (sass) task
Fatal error: The implementation option must be passed to the Sass task

我尝试重新安装 grunt、node、npm、依赖项 - 但我总是回到这个我无法克服的错误。

我应该发布我的 Gruntfile.js 吗?坦率地说,这是由第三方设置的,我们不经常使用它——我想也许我们应该从头开始,因为它最初是从大约 4 年前开始的……但想知道是否有人看过此错误之前并知道修复/解决方法。

【问题讨论】:

  • 可能需要 sass 任务来帮助您

标签: npm sass gruntjs node-sass gruntfile


【解决方案1】:

随着 grunt-sass 3 的更新,你必须选择是使用 node-sass 还是 dart-sass 来编译 对于 node-sass,您需要安装模块:

$ npm install --save-dev node-sass 

在您的 gruntfile 中,您需要添加 node-sass 作为要求并添加定义常量作为实现选项:

const sass = require('node-sass');

require('load-grunt-tasks')(grunt);

grunt.initConfig({
    sass: {
        options: {
            implementation: sass,
            sourceMap: true
        },
        dist: {
            files: {
                'main.css': 'main.scss'
            }
        }
    }
});

更多详情请见官方页面:https://www.npmjs.com/package/grunt-sass

【讨论】:

    【解决方案2】:

    使用这个

       **const sass = require("node-sass");**
    
    **grunt.initConfig({
    sass: {
      options: {
        implementation: sass,
        sourceMap: true,
      },
      dist: {
        files: {
          "css/styles.css": "css/styles.css",
        },
      },
    },
    

    });

    这将帮助您解决问题

    【讨论】:

      【解决方案3】:

      更新:仅适用于 grunt-sass 2.x

      我从 grunt-sass 1.x 升级到 2.x 时遇到了这个问题。这为我解决了这个问题:

      implementation: 'sass' 添加到 Gruntfile.js 中的 sass.options 对象,如下所示:

      options: {
          implementation: 'sass',
          outputStyle: 'expanded',
          sourceMap: true,
          quiet: true // stop depreciation errors
      },
      

      【讨论】:

      • 实现:'sass' 破坏了我的。实现:sass 工作
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多