Nekiy2
Nekiy2

Reputation: 101

Create gulp-sass task (2.0.0) with gulp 4.0.2

gulpfile.js

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

gulp.task('sass', function() {
    return gulp
        .src('scss/main.scss')
        .pipe(sass())
        .pipe(gulp.dest('css/'))
});

task

{
    // See https://go.microsoft.com/fwlink/?LinkId=733558 
    // for the documentation about the tasks.json format
    "version": "2.0.0",
    "tasks": [
        {
            "label": "sass",
            "type": "gulp",
            "task": "sass",
            "problemMatcher": [
                "$eslint-stylish"
            ]
        }
    ]
}

gulp version 4.0.2 gulp CLI version 2.2.0 gulp-sass version 4.0.2

If i try on terminal > gulp sass, its working well If i try Ctrl+Shift+P -> run task - get error:

Error: The gulp task detection didn't contribute a task for the following configuration:

Upvotes: 0

Views: 342

Answers (1)

Nekiy2
Nekiy2

Reputation: 101

I find my mistake:

const gulp = require('gulp');
const sass = require('gulp-sass');
const sasssrc = ['scss/*.scss'];

function scss (){
    return gulp
        .src(sasssrc)
        .pipe(sass())
        .pipe(gulp.dest('css'));
}
exports.scss = scss;

with task.json:

{
    // See https://go.microsoft.com/fwlink/?LinkId=733558 
    // for the documentation about the tasks.json format
    "version": "2.0.0",
    "tasks": [
        {
            "label": "sass",
            "type": "gulp",
            "task": "scss",
            "problemMatcher": [
                "$eslint-stylish"
            ]
        }
    ]
}

Upvotes: 2

Related Questions