Gulp - 不要'看'sass

时间:2016-08-08 18:47:15

标签: npm gulp gulp-watch

我开始使用Gulp进行项目,但是我有一点问题 BrowersSync在手表上工作正常,但是SASS不能在手表上编译(manualy工作正常)。这是我的gulpfile.js - 哪里有问题?

var gulp = require('gulp');
var sass = require('gulp-sass');
var imagemin = require('gulp-imagemin');
var browserSync = require('browser-sync').create();
var cache = require('gulp-cache');

gulp.task('sass', function(){
    return gulp.src('./dev/sass/*.scss')
        .pipe(sass()) // Using gulp-sass
        .pipe(gulp.dest('./assets/css'))
        .pipe(browserSync.reload({
            stream: true
        }))
});

gulp.task('images', function(){
  return gulp.src('./dev/images/**/*.+(png|jpg|jpeg|gif|svg)')
  // Caching images that ran through imagemin
  .pipe(cache(imagemin({
      interlaced: true
    })))
  .pipe(gulp.dest('./assets/images'))
});

gulp.task('browserSync', function() {
    browserSync.init({
        server: {
            baseDir: ''
        },
    })
});

gulp.task( 'watch', ['browserSync', 'sass'], function () {
    gulp.watch( './dev/sass/*.scss', ['sass'] ); 
    gulp.watch( '*.html', browserSync.reload );
});

修改 这是来自控制台的日志:

D:\eSports-Ground\Portal>gulp watch
(node:9416) 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.
[21:49:16] Using gulpfile D:\eSports-Ground\Portal\gulpfile.js
[21:49:16] Starting 'browserSync'...
[21:49:16] Finished 'browserSync' after 13 ms
[21:49:16] Starting 'sass'...
[BS] 1 file changed (style.css)
[21:49:16] Finished 'sass' after 39 ms
[21:49:16] Starting 'watch'...
[21:49:16] Finished 'watch' after 12 ms
[BS] Access URLs:
 -------------------------------------
       Local: http://localhost:3000
    External: http://192.168.56.1:3000
 -------------------------------------
          UI: http://localhost:3001
 UI External: http://192.168.56.1:3001
 -------------------------------------
[BS] Serving files from: ./

0 个答案:

没有答案
相关问题