Gulp表示没有对.jsx的变化做出反应

时间:2016-07-02 23:54:11

标签: javascript gulp-watch

我的gulpfile.js不会对.jsx文件中的更改做出反应。我做错了什么吗?

当我在./frontend/dev/js/*.jsx中更改.jsx文件时,不会显示任何输出。

"use strict";

var gulp    = require('gulp');
var gutil   = require("gulp-util");
var browserSync = require('browser-sync');
var sass    = require('gulp-sass');
var cleanCSS    = require('gulp-clean-css');
var webpack     = require('webpack-stream');

var reload  = browserSync.reload;

//compile the sass files
gulp.task('compile_scss', function () {
    gutil.log("compiling scss..");

    return gulp.src('./frontend/dev/scss/*.scss')
        .pipe(sass())
        .pipe(cleanCSS())
        .pipe(gulp.dest('./frontend/dist/'));
});

//compile js files
gulp.task('compile_js', function () {
    gutil.log("Compiling js files..");

    return gulp.src('./frontend/dev/js/entry.jsx')
        .pipe(webpack())
        .pipe(gulp.dest('./frontend/dist/'));
    //return gulp.pipe(webpack( require("./webpack.config.js") ));
});

// watch files for changes and reload
gulp.task('serve', ["compile_js", "compile_scss"], function() {
    browserSync({
        server: { baseDir: 'frontend' }
    });

    gutil.log("INITIATING!");


    // Compilers
    gulp.watch('dev/scss/**/*.scss',    ['compile_scss']); 
    gulp.watch('dev/js/**/*.jsx',       ['compile_js']); // WATCHING FOR JSX CHANGES

    // Site updates
    gulp.watch(['*.html', 'dist/**/*.css', 'dist/**/*.js'], {cwd: 'frontend'}, reload);
});

文件夹概述:

前端

-dev

- js的

- SCSS

-dist

-index.html

0 个答案:

没有答案