diff --git a/.nodemonignore b/.nodemonignore index 96b6d8ae9c..b368c0d00f 100644 --- a/.nodemonignore +++ b/.nodemonignore @@ -1 +1,2 @@ -/public/* \ No newline at end of file +/views/* +/public/build/* \ No newline at end of file diff --git a/Gruntfile.js b/Gruntfile.js index 11e435f28e..a8f5a01d30 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -99,6 +99,18 @@ module.exports = function(grunt) { 'public/build/static.css': ['public/build/static.css'] } } + }, + + exec: { + start: { + cmd: function(mode){ + if(mode && mode == 'production'){ + return 'nodemon --exec "./start.sh" production' + }else{ + return 'nodemon --exec "./start.sh"' + } + } + } } /*hashres: { @@ -117,8 +129,10 @@ module.exports = function(grunt) { }); // Register tasks. - grunt.registerTask('build', ['clean:build', 'uglify', 'stylus', 'cssmin']); - grunt.registerTask('run', ['clean:build', 'stylus', 'cssmin']); + grunt.registerTask('production', ['clean:build', 'uglify', 'stylus', 'cssmin']); + grunt.registerTask('development', ['clean:build', 'stylus', 'cssmin']); + grunt.registerTask('start:production', ['exec:start:production']); + grunt.registerTask('start', ['exec:start']); // Load tasks grunt.loadNpmTasks('grunt-contrib-uglify'); @@ -126,5 +140,6 @@ module.exports = function(grunt) { grunt.loadNpmTasks('grunt-contrib-clean'); grunt.loadNpmTasks('grunt-contrib-stylus'); grunt.loadNpmTasks('grunt-contrib-cssmin'); + grunt.loadNpmTasks('grunt-exec'); }; diff --git a/README.md b/README.md index 7a4136bb4a..74e0f3a427 100644 --- a/README.md +++ b/README.md @@ -15,7 +15,7 @@ Or, expressed in commands on the command line: 1. `git clone --recursive -b angular_rewrite https://github.com/lefnire/habitrpg.git` 1. `cd habitrpg && npm install` -1. `npm start` +1. `grunt start` (`grunt start:production` to concat & minify js) To access the site, open http://localhost:3000 in your browser. @@ -76,7 +76,7 @@ Ignore this error and proceed with the following: 1. Run 'npm install -g bower' 1. Run 'bower install -f' 1. Run 'copy config.json.example config.json' -1. Run 'npm start' +1. `grunt start` (`grunt start:production` to concat & minify js) Open a browser to URL http://localhost:3000 to test the application. diff --git a/package.json b/package.json index 5cb92d725f..f2c891fe7b 100644 --- a/package.json +++ b/package.json @@ -31,6 +31,7 @@ "grunt-contrib-stylus": "~0.8.0", "grunt-contrib-clean": "~0.5.0", "grunt-contrib-cssmin": "~0.6.1", + "grunt-exec": "~0.4.x", "bower": "~1.2.4", "nib": "~1.0.1", "jade": "~0.35.0", @@ -48,7 +49,6 @@ "npm": "1.2.x" }, "scripts": { - "start": "nodemon src/server.js", "test": "mocha test/api.mocha.coffee", "postinstall": "./node_modules/bower/bin/bower install -f" } diff --git a/start.sh b/start.sh new file mode 100755 index 0000000000..05885587fa --- /dev/null +++ b/start.sh @@ -0,0 +1,11 @@ +#!/bin/sh + +if [ $1 = "production" ]; then + echo "Starting production server"; + grunt production; +else + echo "Starting development server"; + grunt development; +fi + +node ./src/server.js \ No newline at end of file