Skip to content

Commit

Permalink
update grunt server task to refresh when any src files are changed
Browse files Browse the repository at this point in the history
  • Loading branch information
edoparearyee committed Nov 11, 2015
1 parent c53cf23 commit 542ee23
Showing 1 changed file with 60 additions and 38 deletions.
98 changes: 60 additions & 38 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ module.exports = function (grunt) {
var base = grunt.option('base-dir') || '',
env = grunt.option('env') || 'development',
protractorConf = grunt.option('ci') ?
'./tests/e2e/protractor.saucelabs.conf.js' :
'./tests/e2e/protractor.conf.js' ;
'./tests/e2e/protractor.saucelabs.conf.js':
'./tests/e2e/protractor.conf.js';

grunt.initConfig({

Expand All @@ -35,8 +35,8 @@ module.exports = function (grunt) {
livereload: true,
middleware: function ( connect, options, middlewares ) {
var rules = (base === 'dist') ?
[ '^/[^\.]*$ /index.html' ] :
[ '^/app/[^\.]*$ /app/index.html' ];
[ '^/[^\.]*$ ./index.html' ] :
[ '^/app/[^\.]*$ ./app/index.html' ];
middlewares.unshift( modRewrite( rules ) );
return middlewares;
}
Expand All @@ -48,7 +48,7 @@ module.exports = function (grunt) {
livereload: false,
base: '<%= config.outputDir %>',
middleware: function ( connect, options, middlewares ) {
var rules = [ '^/[^\.]*$ /index.html' ];
var rules = [ '^/[^\.]*$ ./index.html' ];
middlewares.unshift( modRewrite( rules ) );
return middlewares;
}
Expand All @@ -58,7 +58,7 @@ module.exports = function (grunt) {

watch: {
options: {
nospawn: false,
spawn: true,
livereload: true
},
html: {
Expand All @@ -85,6 +85,10 @@ module.exports = function (grunt) {
},
javascript: {
files: [
'./app/data/*.json',
'./app/data/**/*.json',
'./app/data/**/**/*.json',

'./app/js/*.js',
'./app/js/**/*.js',
'./app/js/**/**/*.js',
Expand All @@ -93,13 +97,41 @@ module.exports = function (grunt) {
'./tests/unit/**/*.js',
'./tests/unit/**/**/*.js'
],
tasks: ['test:development'],
tasks: ['test:development']
},
scriptsJson: {
files: [
'./scripts.json'
],
tasks: ['sails-linker'],
tasks: ['sails-linker']
},
refresh: {
files: [
'./app/index.html',

'./app/data/*.json',
'./app/data/**/*.json',
'./app/data/**/**/*.json',

'./app/less/*.less',
'./app/less/**/*.less',
'./app/less/**/**/*.less',

'./app/partials/*.html',
'./app/partials/**/*.html',
'./app/partials/**/**/*.html',

'./app/js/*.js',
'./app/js/**/*.js',
'./app/js/**/**/*.js',

'./modules/*.html',
'./modules/**/*.html',
'./modules/**/**/*.html',

'./scripts.json'
],
tasks: ['precompile']
}
},

Expand Down Expand Up @@ -259,10 +291,7 @@ module.exports = function (grunt) {
},

clean: {
beforeBuild: {
src: ['<%= config.outputDir %>', './docs']
},
afterTest: {
dist: {
src: ['<%= config.outputDir %>']
}
},
Expand Down Expand Up @@ -402,7 +431,7 @@ module.exports = function (grunt) {
grunt.loadNpmTasks('grunt-htmllint');

grunt.registerTask('build', [
'clean:beforeBuild',
'clean:dist',
'less:production',
'ngconstant',
'minify',
Expand All @@ -416,57 +445,50 @@ module.exports = function (grunt) {
'bump-commit'
]);

grunt.registerTask('minify', [
'concat',
'uglify'
]);

grunt.registerTask('server', [
'less:development',
'ngconstant',
'sails-linker',
'precompile',
'connect:server',
'watch:css'
'watch:refresh'
]);

grunt.registerTask('serverjs', [
'less:development',
'ngconstant',
'sails-linker',
grunt.registerTask('serverall', [
'precompile',
'connect:server',
'watch:javascript'
'watch'
]);

grunt.registerTask('serverall', [
grunt.registerTask('precompile', [
'less:development',
'ngconstant',
'sails-linker',
'connect:server',
'watch'
'sails-linker'
]);

grunt.registerTask('lint', [
'htmllint',
'lesslint'
'lesslint',
'jshint'
]);

grunt.registerTask('minify', [
'concat',
'uglify'
]);

grunt.registerTask('test', [
'clean:beforeBuild',
'clean:dist',
'ngconstant',
'minify',
'jshint',
'jasmine:production',
'clean:afterTest'
'clean:dist'
]);

grunt.registerTask('test:development', [
'ngconstant',
'jshint',
'jasmine:development'
]);

grunt.registerTask('e2e', [
'clean:beforeBuild',
'clean:dist',
'less:production',
'ngconstant',
'minify',
Expand All @@ -475,7 +497,7 @@ module.exports = function (grunt) {
'connect:servertest',
'protractor_webdriver',
'protractor:dist',
'clean:afterTest'
'clean:dist'
]);

grunt.registerTask('default', ['build']);
Expand Down

0 comments on commit 542ee23

Please sign in to comment.