gulp watch和lint似乎无法改变文件

时间:2017-02-22 21:06:12

标签: javascript node.js gulp

我有问题让我的gulp watch和eslint工作更改文件和eslint根本不运行。

我的gulp文件如下所示:

"use strict";

var gulp = require('gulp');
var connect = require('gulp-connect');
var open = require('gulp-open');
var browserify = require('browserify');
var reactify = require('reactify');
var source = require('vinyl-source-stream');
var concat = require('gulp-concat');
var lint = require('gulp-eslint');




var config = {
    port: 8080,
    devBaseUrl: 'http://localhost',
    paths: {
        html: './src/*.html',
        js: './src/**/.js',
        css: [
            'node_modules/bootstrap/dist/css/bootstrap.min.css',
            'node_modules/bootstrap/dist/css/bootstrap-theme.min.css'
        ],
        dist: './dist',
        mainJs: './src/main.js'
    }
}

gulp.task('connect', function () {
    connect.server({
        root: ['dist'],
        port: config.port,
        base: config.devBaseUrl,
        livereload: true
    });
});

gulp.task('open', ['connect'], function () {
    gulp.src('dist/index.html')
        .pipe(open({ uri: config.devBaseUrl + ':' + config.port + '/'}));
});

gulp.task('html', function () {
    gulp.src(config.paths.html)
    .pipe(gulp.dest(config.paths.dist))
    .pipe(connect.reload());
});

gulp.task('js', function() {
    browserify(config.paths.mainJs)
        .transform(reactify)
        .bundle()
        .on('error', console.error.bind(console))
        .pipe(source('bundle.js'))
        .pipe(gulp.dest(config.paths.dist + '/scripts'))
        .pipe(connect.reload());
});

gulp.task('css', function () {
    gulp.src(config.paths.css)
        .pipe(concat('bundle.css'))
        .pipe(gulp.dest(config.paths.dist + '/css'))
});

gulp.task('lint', function () {
    return gulp.src(config.paths.js)
        .pipe(lint({config: 'eslint.config.json'}))
        .pipe(lint.format());
});


gulp.task('watch', function () {
    gulp.watch(config.paths.html, ['html']);
    gulp.watch(config.paths.js, ['js', 'lint']);
});

gulp.task('default', ['html', 'js', 'css', 'lint', 'open', 'watch']);

我没有收到任何错误,这就是控制台显示的内容:

[16:00:44] Using gulpfile ~/reactbegin/gulpfile.js
[16:00:44] Starting 'html'...
[16:00:44] Finished 'html' after 7.76 ms
[16:00:44] Starting 'js'...
[16:00:44] Finished 'js' after 13 ms
[16:00:44] Starting 'css'...
[16:00:44] Finished 'css' after 5.13 ms
[16:00:44] Starting 'lint'...
[16:00:44] Starting 'connect'...
[16:00:44] Finished 'connect' after 12 ms
[16:00:44] Starting 'open'...
[16:00:44] Finished 'open' after 3.91 ms
[16:00:44] Starting 'watch'...
[16:00:44] Finished 'watch' after 19 ms
[16:00:44] Server started http://localhost:8080
[16:00:44] LiveReload started on port 35729
[16:00:44] Opening http://localhost:8080/ using the default OS app
[16:00:44] Finished 'lint' after 92 ms
[16:00:44] Starting 'default'...
[16:00:44] Finished 'default' after 2.77 μs

0 个答案:

没有答案