Category Archives: grunt

Using Grunt watch all your javascript changes —- Build a node.js website –part5

first install this dependance by run npm install grunt-cli -g (g means:install this in the globle level)

nodejsWebsite14

For node.js website run also need run npm install grunt-nodemon -save-dev (-save mean will add a reference to the package.json file, -dev means this only for developer )

then go to the project root level create a file name: gruntfile.js

//gruntfile.js
module.exports = function (grunt) {
grunt.initConfig({
nodemon: {
all: {
scripts: ‘app.js’,
options: {
watchedExtensions:[‘js’]//ask grunt watch all the js file
}
}
},
});

grunt.loadNpmTasks(‘grunt-nodemon’);
grunt.registerTask(‘default’, [‘nodemon’]);
};

once this has been done, then go the command run grunt;

then everytime your change in your project, grunt will auto restart the serve.js, I could just refresh the page don’t need to restart the server.