简体   繁体   English

gulp-ruby-sass错误:必须提供模式

[英]gulp-ruby-sass Error: must provide pattern

This is my directory structure: 这是我的目录结构:

这里

I set up my workstation, and I set up my Gulp File to work on my folder format, but it is not working properly. 我设置了我的工作站,并设置了我的Gulp文件以处理我的文件夹格式,但它无法正常工作。

This is my Gulp File: 这是我的Gulp文件:

var gulp      = require('gulp'),
    sass        = require('gulp-ruby-sass'),
    imagemin    = require('gulp-imagemin'),
    changed     = require('gulp-changed'),
    browserSync = require('browser-sync'),
    livereload = require('gulp-livereload'),    
    gp_concat = require('gulp-concat'),
    gp_rename = require('gulp-rename'),
    gp_uglify = require('gulp-uglify'),
    watch = require('gulp-watch');


gulp.task('sass', function () {
  gulp.src('./app/template/css/style_v1.scss')
    .pipe(sass())
    .on('error', function (err) { console.log(err.message); })
    .pipe(gulp.dest('./dist/css'))
    .pipe(livereload());
});

gulp.task('compress', function() {
  gulp.src('./app/*.js')
   .pipe(gp_concat('concat.js'))
        .pipe(gulp.dest('dist'))
        .pipe(gp_rename('script.min.js'))
        .pipe(gp_uglify())
        .pipe(gulp.dest('./dist/js'));
});

gulp.task('jpg', function() {
    gulp.src('./template/img/**/*.*')
        .pipe(changed('./dist/img/'))
        .pipe(imagemin({
            progressive: true
        }))
        .pipe(gulp.dest('./dist/img/'));
});

gulp.task('browser-sync', function() {
    browserSync.init(['./dist/css/**', 'index.php'], {
        server: {
            baseDir: './',
            index: 'index.php'
        }
    });
});

gulp.task('watch', ['sass', 'browser-sync','compress'], function () { 
    return watch('./app/template/css/style_v1.scss', function () {
        gulp.src('./app/template/css/style_v1.scss')
            .pipe(gulp.dest('build'));
    });
});

When I run gulp watch it returns this: 当我运行gulp watch它会返回:

(node:6668) fs: re-evaluating native module sources is not supported. If you are using the graceful-fs module, please update it to a more recent version.
[08:42:23] Using gulpfile /var/www/html/evandro/sistema_metas/gulpfile.js
[08:42:23] Starting 'sass'...
[08:42:23] 'sass' errored after 7.09 ms
[08:42:23] Error: must provide pattern

What is the problem? 问题是什么?

I have another code, the CSS Watch does not work, just watch HTML, What can it be? 我有另一个代码,CSS Watch不起作用,只看HTML,它有什么用?

gulp-ruby-sass works differently from other gulp plugins. gulp-ruby-sass与其他gulp插件的工作方式不同。 You don't pass it to .pipe() . 你没有把它传递给.pipe() If you take a look at the documentation it says the following: 如果您查看文档,则说明以下内容:

Use gulp-ruby-sass instead of gulp.src to compile Sass files. 使用gulp.src -ruby-sass 而不是gulp.src来编译Sass文件。

That means you have to use it like this: 这意味着你必须像这样使用它:

var sass = require('gulp-ruby-sass');

gulp.task('sass', function () {
  return sass('./app/template/css/style_v1.scss')
    .on('error', function (err) { console.log(err.message); })
    .pipe(gulp.dest('./dist/css'))
    .pipe(livereload());
});

Alternatively you can use the gulp-sass plugin instead of gulp-ruby-sass . 或者你可以使用gulp-sass插件而不是gulp-ruby-sass It doesn't use the Ruby implementation of SASS, but rather the C implementation (libsass). 它不使用SASS的Ruby实现,而是使用C实现(libsass)。 It allows you to use .pipe() as you normally would for most other gulp plugins: 它允许你像往常一样使用.pipe()对大多数其他gulp插件:

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

gulp.task('sass', function () {
  return gulp.src('./app/template/css/style_v1.scss')
    .pipe(sass())
    .on('error', function (err) { console.log(err.message); })
    .pipe(gulp.dest('./dist/css'))
    .pipe(livereload());
});

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM