Create a grunt task for running in development

This commit is contained in:
Rowan Manning
2013-11-07 10:16:33 +00:00
parent ab31497b64
commit 4b07da1f0c
3 changed files with 19 additions and 4 deletions

View File

@@ -29,6 +29,18 @@ module.exports = function (grunt) {
} }
}, },
nodemon: {
development: {
options: {
cwd: __dirname,
file: 'index.js',
env: {
NODE_ENV: 'development'
}
}
}
},
uglify: { uglify: {
options: { options: {
mangle: false mangle: false
@@ -67,9 +79,11 @@ module.exports = function (grunt) {
grunt.loadNpmTasks('grunt-contrib-less'); grunt.loadNpmTasks('grunt-contrib-less');
grunt.loadNpmTasks('grunt-contrib-uglify'); grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-contrib-watch'); grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-nodemon');
grunt.registerTask('lint', ['jshint']); grunt.registerTask('lint', ['jshint']);
grunt.registerTask('compile', ['less', 'uglify']); grunt.registerTask('compile', ['less', 'uglify']);
grunt.registerTask('start', ['nodemon:development']);
grunt.registerTask('default', ['compile', 'lint']); grunt.registerTask('default', ['compile', 'lint']);
grunt.registerTask('ci', ['compile', 'lint']); grunt.registerTask('ci', ['compile', 'lint']);

View File

@@ -30,11 +30,11 @@ Each of these files defines configurations for a different environment. If you'r
Now that you've got your application configured, you can run in each mode with the following commands: Now that you've got your application configured, you can run in each mode with the following commands:
```sh ```sh
$ NODE_ENV=production node . $ NODE_ENV=production node . # Run in production
$ NODE_ENV=development ./node_modules/.bin/supervisor -q . $ NODE_ENV=development node . # Run in development
``` ```
Development mode runs the application with [Supervisor][supervisor], so you won't need to restart it if you change any JavaScript files. See [development instructions](#development) for more information about running locally (and restarting automatically when files change).
Configurations Configurations
@@ -60,6 +60,7 @@ Now you'll be able to run the following commands:
$ grunt # Run the lint and test tasks together $ grunt # Run the lint and test tasks together
$ grunt lint # Run JSHint with the correct config $ grunt lint # Run JSHint with the correct config
$ grunt compile # Compile front-end assets $ grunt compile # Compile front-end assets
$ grunt start # Run app in development mode, restarting if files change
$ grunt watch # Watch for file changes and compile assets $ grunt watch # Watch for file changes and compile assets
``` ```

View File

@@ -36,7 +36,7 @@
"grunt-contrib-less": "~0.8", "grunt-contrib-less": "~0.8",
"grunt-contrib-uglify": "~0.2", "grunt-contrib-uglify": "~0.2",
"grunt-contrib-watch": "~0.5", "grunt-contrib-watch": "~0.5",
"supervisor": "~0.5" "grunt-nodemon": "~0.1"
}, },
"scripts": { "scripts": {