Run multiple servers with support for automatically restarting on file changes.
This plugin requires Grunt ~0.4.5
If you haven't used Grunt before, be sure to check out the Getting Started guide, as it explains how to create a Gruntfile as well as install and use Grunt plugins. Once you're familiar with that process, you may install this plugin with this command:
npm install grunt-run-last --save-dev
Once the plugin has been installed, it may be enabled inside your Gruntfile with this line of JavaScript:
grunt.loadNpmTasks('grunt-run-last');
In your project's Gruntfile, add a section named run_last
to the data object passed into grunt.initConfig()
.
grunt.initConfig({
run_last: {
server: {
file: 'app.js',
env: { NODE_ENV: 'production'}
},
nightmare: {
file: 'nightmare.js',
},
},
});
In this example, servers reload automatically on file changes.
grunt.initConfig({
run_last: {
server: {
file: 'app.js',
},
nightmare: {
file: 'nightmare.js'
}
},
watch: {
options: {spawn: false},
server: {
files: ['*.js'],
tasks: ['run_last:server']
},
nightmare: {
files: ['nightmare.js'],
tasks: ['run_last:nightmare']
}
}
});
Run grunt w
to start the servers. Then modify server source file(s) and save.