The implementation option must be passed to the Sass task

DrewM picture DrewM · Aug 14, 2018 · Viewed 9.2k times · Source

Running grunt - I get this error message:

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

I've tried re-installing grunt, node, npm, dependencies - but I always come back to this error I can't get past.

Should I post my Gruntfile.js? Frankly, this was set up by a third-party and we don't use it often - I'm thinking maybe we should start from the ground up because it is from about 4 years ago originally... but wondering if anyone has seen this error before and knows of a fix/workaround.

Answer

Th3S4mur41 picture Th3S4mur41 · Nov 14, 2018

With the update to grunt-sass 3, you have to choose whether you want to use node-sass or dart-sass to compile For node-sass you need to install the module with:

$ npm install --save-dev node-sass 

In you gruntfile, you than need to add node-sass as requirement and add the define constant as implementation option:

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

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

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

See also official page for more details: https://www.npmjs.com/package/grunt-sass