askcoder
askcoder

Reputation: 883

gulp-sass 5 does not have a default Sass compiler scss files to compile

I am working on a project just starting with gulp, and I am getting this error :

gulp-sass 5 does not have a default Sass compiler; please set one yourself

when I run gulp styles I have tried a lot of solutions found on stackoverflow and googled for solution but none of them has worked. This is my code (File gulpfile.babeljs)

import gulp from 'gulp';
import yargs from 'yargs';
import sass from 'gulp-sass';
const PRODUCTION = yargs.argv.prod;

export const styles = () => {
    return gulp.src('src/assets/scss/bundle.scss')
        .pipe(sass().on('error', sass.logError))
        .pipe(gulp.dest('dist/asset/css'));
}

Please note that the files in src/assets/scss/components has as extension 'scss'

Thanks in advance

Upvotes: 1

Views: 2084

Answers (1)

askcoder
askcoder

Reputation: 883

I have got the solution and it works :

npm install --save-dev sass

and then this is the full modified code

import gulp from 'gulp';
import yargs from 'yargs';
const sass = require('gulp-sass')(require('sass'));
const PRODUCTION = yargs.argv.prod;

export const styles = () => {
    return gulp.src('src/assets/scss/bundle.scss')
        .pipe(sass().on('error', sass.logError))
        .pipe(gulp.dest('dist/asset/css'));
}

Upvotes: 1

Related Questions