Open Alexorz opened 10 years ago
+1
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'
}
}
}
});
};
Is this still an issue? Wondering if I should use this library.
This is still an issue!
It has been such a long time, I'm using KOA and Gulp now...
This module seems to be no longer maintained.
When I modified
.scss
files, there should be a compass compiling that triggered by taskwatch
, but actually nothing happend. Thewatch
task seems to be interrupted by taskexpress-server
.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