Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

watch task be interrupted by express-server #70

Open
Alexorz opened this issue Nov 4, 2014 · 5 comments
Open

watch task be interrupted by express-server #70

Alexorz opened this issue Nov 4, 2014 · 5 comments

Comments

@Alexorz
Copy link

Alexorz commented Nov 4, 2014

When I modified .scss files, there should be a compass compiling that triggered by task watch, but actually nothing happend. The watch task seems to be interrupted by task express-server.

image

Demo project here:
https://github.com/Alexorz/grunt-express-angular-example/tree/Demo_for_issue_2

Versions:
grunt-express: 1.4.0 (got another issue on 1.4.1)
express: 4.10.1

@leohgbs
Copy link

leohgbs commented Nov 19, 2014

+1

@klode
Copy link

klode commented Dec 15, 2014

I also have a similar problem.

    grunt.registerTask('default', [
        'build',
//        'express:livereload',
        'open',
        'watch'
    ]);

The watch task does not work any more when I use express:livereload

I also have a small test app that reproduces this problem, I can load it on git if can be useful.

grunt-express 1.4.0
express 4.10.6

Gruntfile.js

module.exports = function(grunt) {

    var path = require('path');

    grunt.loadNpmTasks('grunt-contrib-concat');
    grunt.loadNpmTasks('grunt-contrib-jshint');
    grunt.loadNpmTasks('grunt-contrib-uglify');
    grunt.loadNpmTasks('grunt-contrib-clean');
    grunt.loadNpmTasks('grunt-contrib-copy');
    grunt.loadNpmTasks('grunt-contrib-watch');
    grunt.loadNpmTasks('grunt-contrib-sass');
    grunt.loadNpmTasks('grunt-open');
    grunt.loadNpmTasks('grunt-express');
    grunt.loadNpmTasks('grunt-html2js');

    grunt.registerTask('default', [
        'build',
        'express:livereload',    // with this task 'watch' stops to work
        'open',
        'watch'
    ]);

    grunt.registerTask('build', [
        'clean:dist',
        'html2js:app',
        'jshint',
        'concat',
        'sass:dev',
        'clean:temp'
    ]);

    // Print a timestamp (useful for when watching)
    grunt.registerTask('timestamp', function() {
        grunt.log.subhead(Date());
    });

    grunt.initConfig({

        distdir: 'dist',
        tempdir: 'tmp',
        pkg: grunt.file.readJSON('package.json'),
        banner:
        '/*! <%= pkg.title || pkg.name %> - v<%= pkg.version %> - <%= grunt.template.today("yyyy-mm-dd") %> */\n',
        src: {
            js: [
                'src/js/**/*.js'
            ],
            jsTpl: '<%= tempdir %>/templates.js',
            tpl: {
                app: ['src/views/partials/*.html']
            },
            html: {
                index: 'src/views/index.html'
            }
        },
        html2js: {
            app: {
                options: {
                    base: 'src/views'
                },
                src: '<%= src.tpl.app %>',
                dest: '<%= src.jsTpl %>'
            }
        },
        concat: {
            dist: {
                options: {
                    banner: "<%= banner %>"
                },
                src: ['<%= src.js %>', '<%= src.jsTpl %>'],
                dest: '<%= distdir %>/<%= pkg.name %>.js'
            },
            index: {
                src: ['<%= src.html.index %>'],
                dest: '<%= distdir %>/index.html',
                options: {
                    process: true
                }
            },
            angular: {
                src: ['bower_components/angular/angular.js',
                    'bower_components/angular-route/angular-route.js',
                    'bower_components/angular-resource/angular-resource.js'
                ],
                dest: '<%= distdir %>/angular.js'
            },
            underscore: {
                src: ['bower_components/underscore/underscore.js'],
                dest: '<%= distdir %>/underscore.js'
            },
            jquery: {
                src: ['bower_components/jquery/dist/jquery.js'],
                dest: '<%= distdir %>/jquery.js'
            }
        },
        uglify: {
            dist: {
                options: {
                    banner: "<%= banner %>"
                },
                src: ['<%= src.js %>', '<%= src.jsTpl %>'],
                dest: '<%= distdir %>/<%= pkg.name %>.js'
            },
            angular: {
                src: ['<%= concat.angular.src %>'],
                dest: '<%= distdir %>/angular.js'
            },
            underscore: {
                src: ['bower_components/underscore/underscore.js'],
                dest: '<%= distdir %>/underscore.js'
            },
            jquery: {
                src: ['bower_components/jquery/dist/jquery.js'],
                dest: '<%= distdir %>/jquery.js'
            }
        },
        clean: {
            temp: {
                src: ['<%= tempdir %>']
            },
            dist: {
                src: ['<%= distdir %>/*']
            }
        },
        watch: {
            build: {
                files: ['<%= src.js %>', '<%= src.tpl.app %>', '<%= src.html.index %>'],
                tasks: ['build', 'timestamp']
            },
            sass: {
                files: 'src/styles/{,*/}*.{scss,sass}',
                tasks: ['sass:dev']
            }
        },
        open: {
            server: {
                url: 'http://<%= express.options.hostname %>:<%= express.options.port %>'
            }
        },
        express: {
            options: {
                port: 9095,
                hostname: 'localhost'
            },
            livereload: {
                options: {
                    server: path.resolve('../server/server'),
                    livereload: true,
                    serverreload: true,
                    bases: [path.resolve('./dist')]
                }
            }
        },
        jshint: {
            files: ['Gruntfile.js', '<%= src.js %>', '<%= src.jsTpl %>'],
            options: {
                curly: true,
                eqeqeq: true,
                immed: true,
                latedef: true,
                newcap: true,
                noarg: true,
                sub: true,
                boss: true,
                eqnull: true,
                globals: {}
            }
        },
        sass: {
            dev: {
                options: {
                    style: 'expanded',
                    compass: false
                },
                files: {
                    '<%= distdir %>/css/app.css': 'src/styles/main.scss'
                }
            }
        }
    });
};

@jme783
Copy link

jme783 commented Mar 19, 2015

Is this still an issue? Wondering if I should use this library.

@bmhung
Copy link

bmhung commented Mar 29, 2016

This is still an issue!

@Alexorz
Copy link
Author

Alexorz commented Mar 30, 2016

It has been such a long time, I'm using KOA and Gulp now...

This module seems to be no longer maintained.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants