sass - 使用 gulp 4.0.2 创建 gulp-sass 任务 (2.0.0)
问题描述
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:
解决方案
我发现我的错误:
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"
]
}
]
}
推荐阅读
- c - C - 控制溢出(从键盘插入值)
- typescript - 元素隐式具有“任何”类型,因为类型“typeof globalThis”没有索引签名
- css - 使用 CSS,如何强制响应式商店在 400px 分辨率下的商店中继续显示 2 列?
- sql - 查找开始和结束编号
- javascript - 获取未捕获的类型错误,但链接工作正常
- javascript - 如何修复角度取消订阅
- java - 为什么我无法访问泛型类型类元素?
- c++ - 另一个构造函数中的对象构造函数?
- android - Android UI 测试 - 检查 listView 中的复选框
- c# - 如何从 Weather API XML 打印所有日期