Skip to content

Instantly share code, notes, and snippets.

@marcusgadbem
Created August 14, 2014 22:31
Show Gist options
  • Save marcusgadbem/2399976c4cf6b2b577b2 to your computer and use it in GitHub Desktop.
Save marcusgadbem/2399976c4cf6b2b577b2 to your computer and use it in GitHub Desktop.
grunt-concurrent with nodemon and watch
/* globals module */
module.exports = function(grunt) {
// Project configuration.
grunt.initConfig({
watch: {
gruntfile: {
files: '<%= jshint.gruntfile.src %>',
tasks: ['jshint:gruntfile']
},
sass: {
files: ['src/scss/**/*.scss'],
tasks: ['sass']
},
js: {
files: ['src/js/**/*.js'],
tasks: ['uglify']
}
},
nodemon: {
dev: {
script: 'server.js',
options: {
ext: '*',
watch: ['app'],
env: {
NODE_ENV: "development",
NODE_PORT: "8000",
NODE_IP: "0.0.0.0"
},
callback: function (nodemon) {
nodemon.on('log', function (e) {
grunt.log.writeln(e.colour);
});
nodemon.on('restart', function () {
grunt.log.subhead('Running compile task ... ');
grunt.util.spawn({
grunt: true,
args: ['sass', 'uglify', 'copy-static'],
}, function(err, result) {
grunt.log.debug(result.toString());
if (err || result.code !== 0) {
grunt.log.write('Error while compiling')
.error()
.error(err);
}
grunt.log.subhead('Compile task: \u001b[32mOK\u001B[0m');
});
});
}
}
}
},
concurrent: {
std: {
tasks: ['watch', 'nodemon:dev'],
options: {
logConcurrentOutput: true
}
}
}
grunt.registerTask('copy-static', ['copy:imgs']);
grunt.registerTask('server',
[
'copy-static',
'sass',
'uglify',
'concurrent:std'
]
);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment