【问题标题】:Create gulp-sass task (2.0.0) with gulp 4.0.2使用 gulp 4.0.2 创建 gulp-sass 任务 (2.0.0)
【发布时间】:2019-06-20 15:44:44
【问题描述】:

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

任务

{
    // 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 版本 4.0.2 gulp CLI 版本 2.2.0 gulp-sass 版本 4.0.2

如果我在终端上尝试 > gulp sass,它运行良好 如果我尝试 Ctrl+Shift+P -> 运行任务 - 得到错误:

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

【问题讨论】:

    标签: sass visual-studio-code gulp


    【解决方案1】:

    我发现我的错误:

    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;
    

    带有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"
                ]
            }
        ]
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2019-10-17
      • 1970-01-01
      • 1970-01-01
      • 2015-08-12
      • 2016-08-23
      • 1970-01-01
      • 2015-03-25
      相关资源
      最近更新 更多