首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >使用gulp 4.0.2创建gulp-sass任务(2.0.0)

使用gulp 4.0.2创建gulp-sass任务(2.0.0)
EN

Stack Overflow用户
提问于 2019-06-20 23:44:44
回答 1查看 197关注 0票数 0

gulpfile.js

代码语言:javascript
复制
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/'))
});

任务

代码语言:javascript
复制
{
    // 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

如果我尝试terminal > gulp,如果我尝试Ctrl+Shift+P -> run task get error,它工作正常:

代码语言:javascript
复制
Error: The gulp task detection didn't contribute a task for the following configuration:
EN

回答 1

Stack Overflow用户

发布于 2019-06-21 00:36:33

我发现了我的错误:

代码语言:javascript
复制
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:

代码语言:javascript
复制
{
    // 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"
            ]
        }
    ]
}
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/56689595

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档