208 lines
4.2 KiB
JavaScript
Executable file
208 lines
4.2 KiB
JavaScript
Executable file
'use strict';
|
|
|
|
module.exports = function(grunt) {
|
|
// Unified Watch Object
|
|
var watchFiles = {
|
|
serverViews: ['app/views/**/*.*'],
|
|
serverJS: ['gruntfile.js', 'server.js', 'config/**/*.js', 'app/**/*.js', '!app/tests/'],
|
|
clientViews: ['public/modules/**/views/**/*.html'],
|
|
clientJS: ['public/js/*.js', 'public/modules/**/*.js'],
|
|
clientCSS: ['public/modules/**/*.css'],
|
|
mochaTests: ['app/tests/**/*.js']
|
|
};
|
|
|
|
// Project Configuration
|
|
grunt.initConfig({
|
|
pkg: grunt.file.readJSON('package.json'),
|
|
watch: {
|
|
serverViews: {
|
|
files: watchFiles.serverViews,
|
|
options: {
|
|
livereload: true,
|
|
spawn: false
|
|
}
|
|
},
|
|
serverJS: {
|
|
files: watchFiles.serverJS,
|
|
tasks: ['newer:jshint'],
|
|
options: {
|
|
livereload: true,
|
|
spawn: false
|
|
}
|
|
},
|
|
clientViews: {
|
|
files: watchFiles.clientViews,
|
|
options: {
|
|
livereload: true,
|
|
spawn: false
|
|
}
|
|
},
|
|
clientJS: {
|
|
files: watchFiles.clientJS,
|
|
tasks: ['newer:jshint'],
|
|
options: {
|
|
livereload: true,
|
|
spawn: false
|
|
}
|
|
},
|
|
clientCSS: {
|
|
files: watchFiles.clientCSS,
|
|
tasks: ['newer:csslint'],
|
|
options: {
|
|
livereload: true,
|
|
spawn: false
|
|
}
|
|
},
|
|
mochaTests: {
|
|
files: watchFiles.mochaTests,
|
|
tasks: ['test:server'],
|
|
}
|
|
},
|
|
jshint: {
|
|
all: {
|
|
src: watchFiles.clientJS.concat(watchFiles.serverJS),
|
|
options: {
|
|
jshintrc: true
|
|
}
|
|
}
|
|
},
|
|
csslint: {
|
|
options: {
|
|
csslintrc: '.csslintrc'
|
|
},
|
|
all: {
|
|
src: watchFiles.clientCSS
|
|
}
|
|
},
|
|
uglify: {
|
|
production: {
|
|
options: {
|
|
mangle: false
|
|
},
|
|
files: {
|
|
'public/dist/application.min.js': 'public/dist/application.js'
|
|
}
|
|
}
|
|
},
|
|
cssmin: {
|
|
combine: {
|
|
files: {
|
|
'public/dist/application.min.css': '<%= applicationCSSFiles %>'
|
|
}
|
|
}
|
|
},
|
|
nodemon: {
|
|
dev: {
|
|
script: 'server.js',
|
|
options: {
|
|
nodeArgs: ['--debug'],
|
|
ext: 'js,html',
|
|
watch: watchFiles.serverViews.concat(watchFiles.serverJS)
|
|
}
|
|
}
|
|
},
|
|
'node-inspector': {
|
|
custom: {
|
|
options: {
|
|
'web-port': 1337,
|
|
'web-host': 'localhost',
|
|
'debug-port': 5858,
|
|
'save-live-edit': true,
|
|
'no-preload': true,
|
|
'stack-trace-limit': 50,
|
|
'hidden': []
|
|
}
|
|
}
|
|
},
|
|
ngAnnotate: {
|
|
production: {
|
|
files: {
|
|
'public/dist/application.js': '<%= applicationJavaScriptFiles %>'
|
|
}
|
|
}
|
|
},
|
|
concurrent: {
|
|
default: ['nodemon', 'watch'],
|
|
debug: ['nodemon', 'watch', 'node-inspector'],
|
|
options: {
|
|
logConcurrentOutput: true,
|
|
limit: 10
|
|
}
|
|
},
|
|
env: {
|
|
test: {
|
|
NODE_ENV: 'test',
|
|
},
|
|
secure: {
|
|
NODE_ENV: 'secure'
|
|
},
|
|
options: {
|
|
src: 'ENV.json'
|
|
}
|
|
},
|
|
mochaTest: {
|
|
src: watchFiles.mochaTests,
|
|
options: {
|
|
reporter: 'spec',
|
|
quiet: false,
|
|
require: 'server.js',
|
|
ui: 'bdd'
|
|
}
|
|
},
|
|
karma: {
|
|
unit: {
|
|
configFile: 'karma.conf.js'
|
|
}
|
|
},
|
|
protractor: {
|
|
options: {
|
|
configFile: 'protractor.conf.js',
|
|
keepAlive: true,
|
|
noColor: false
|
|
},
|
|
e2e: {
|
|
options: {
|
|
args: {} // Target-specific arguments
|
|
}
|
|
}
|
|
},
|
|
});
|
|
|
|
// Load NPM tasks
|
|
require('load-grunt-tasks')(grunt);
|
|
|
|
// Making grunt default to force in order not to break the project.
|
|
grunt.option('force', true);
|
|
|
|
// A Task for loading the configuration object
|
|
grunt.task.registerTask('loadConfig', 'Task that loads the config into a grunt option.', function() {
|
|
var init = require('./config/init')();
|
|
var config = require('./config/config');
|
|
|
|
grunt.config.set('applicationJavaScriptFiles', config.assets.js);
|
|
grunt.config.set('applicationCSSFiles', config.assets.css);
|
|
});
|
|
grunt.loadNpmTasks('grunt-html2js');
|
|
|
|
|
|
// Default task(s).
|
|
grunt.registerTask('default', ['lint', 'concurrent:default']);
|
|
|
|
// Debug task.
|
|
grunt.registerTask('debug', ['lint', 'concurrent:debug']);
|
|
|
|
// Secure task(s).
|
|
grunt.registerTask('secure', ['env:secure', 'lint', 'concurrent:default']);
|
|
|
|
// Lint task(s).
|
|
grunt.registerTask('lint', ['newer:jshint', 'newer:csslint']);
|
|
|
|
// Build task(s).
|
|
grunt.registerTask('build', ['lint', 'loadConfig', 'uglify', 'cssmin', 'ngAnnotate' ]);
|
|
|
|
// Test task.
|
|
grunt.registerTask('test', ['test:server', 'test:client']);
|
|
grunt.registerTask('test:server', ['env:test', 'mochaTest']);
|
|
grunt.registerTask('test:client', ['env:test', 'karma:unit']);
|
|
};
|