gimm / gulp-express

gulp plugin for express
56 stars 26 forks source link

Live reload does not function (browser doesn't restart) #48

Open CiscoKidxx opened 8 years ago

CiscoKidxx commented 8 years ago

Gulpfile.js

   var gulp = require('gulp'),
        mainBowerFiles = require('main-bower-files'),
        inject = require('gulp-inject'),
        server = require('gulp-express'),
        del = require('del');

    var paths = {
        temp: '.tmp',
        tempVendor: '.tmp/vendor',
        tempIndex: '.tmp/views/index.html',

        index: 'app/views/index.html',
        appSrc: ['app/**/*', '!app/views/index.html'],
        bowerSrc: 'bower_components/**/*'
    };

    gulp.task('default', ['watch']);

    gulp.task('watch', ['serve'], function () {
        gulp.watch(paths.appSrc, ['scripts']);
        gulp.watch(paths.bowerSrc, ['vendors']);
        gulp.watch(paths.index, ['copyAll']);
    });

    gulp.task('serve', ['copyAll'], function () {
        server.run(['prod.js']);
    });

    gulp.task('copyAll', function () {
        var vendorFiles = gulp.src(mainBowerFiles()).pipe(gulp.dest(paths.tempVendor));
        var appFiles = gulp.src(paths.appSrc).pipe(gulp.dest(paths.temp));

        return gulp.src(paths.index)
            .pipe(gulp.dest(paths.temp))
            .pipe(inject(appFiles, {
                relative: true
            }))
            .pipe(inject(vendorFiles, {
                relative: true,
                name: 'vendorInject'
            }))
            .pipe(gulp.dest(paths.temp));
    });

    gulp.task('vendors', function () {
        var tempVendors = gulp.src(mainBowerFiles()).pipe(gulp.dest(paths.tempVendor));

        return gulp.src(paths.tempIndex)
            .pipe(inject(tempVendors, {
                relative: true,
                name: 'vendorInject'
            }))
            .pipe(gulp.dest(paths.temp))
            .pipe(server.notify());
    });

    gulp.task('scripts', function () {
        var appFiles = gulp.src(paths.appSrc).pipe(gulp.dest(paths.temp));

        return gulp.src(paths.tempIndex)
            .pipe(inject(appFiles, {
                    relative: true
            }))
            .pipe(gulp.dest(paths.temp))
            .pipe(server.notify());
    });

    gulp.task('clean', function () {
        del([paths.temp]);
    });
waltergms commented 7 years ago

Same here.