1 // Generated on 2015-08-31 using generator-angular-fullstack 3.0.0-rc5
4 module.exports = function (grunt) {
7 localConfig = require('./server/config/local.env');
12 // Load grunt tasks automatically, when needed
13 require('jit-grunt')(grunt, {
14 express: 'grunt-express-server',
15 useminPrepare: 'grunt-usemin',
16 ngtemplates: 'grunt-angular-templates',
17 cdnify: 'grunt-google-cdn',
18 protractor: 'grunt-protractor-runner',
19 buildcontrol: 'grunt-build-control',
20 istanbul_check_coverage: 'grunt-mocha-istanbul'
23 // Time how long tasks take. Can help when optimizing build times
24 require('time-grunt')(grunt);
26 // Define the configuration for all the tasks
30 pkg: grunt.file.readJSON('package.json'),
33 client: require('./bower.json').appPath || 'client',
38 port: process.env.PORT || 9000
54 url: 'http://localhost:<%= express.options.port %>'
60 '<%= yeoman.client %>/{app,components}/**/!(*.spec|*.mock).js',
61 '!<%= yeoman.client %>/app/app.js'
63 tasks: ['injector:scripts']
66 files: ['<%= yeoman.client %>/{app,components}/**/*.css'],
67 tasks: ['injector:css']
70 files: ['server/**/*.{spec,integration}.js'],
71 tasks: ['env:test', 'mochaTest']
74 files: ['<%= yeoman.client %>/{app,components}/**/*.{spec,mock}.js'],
75 tasks: ['newer:jshint:all', 'wiredep:test', 'karma']
78 files: ['<%= yeoman.client %>/{app,components}/**/*.{scss,sass}'],
79 tasks: ['injector:sass']
82 files: ['<%= yeoman.client %>/{app,components}/**/*.{scss,sass}'],
83 tasks: ['sass', 'postcss']
86 files: ['Gruntfile.js']
90 '{.tmp,<%= yeoman.client %>}/{app,components}/**/*.{css,html}',
91 '{.tmp,<%= yeoman.client %>}/{app,components}/**/!(*.spec|*.mock).js',
92 '<%= yeoman.client %>/assets/images/{,*//*}*.{png,jpg,jpeg,gif,webp,svg}'
99 files: ['server/**/*.{js,json}'],
100 tasks: ['express:dev', 'wait'],
103 spawn: false //Without this option specified express won't be reloaded
107 files: ['bower.json'],
112 // Make sure code styles are up to par and there are no obvious mistakes
115 jshintrc: '<%= yeoman.client %>/.jshintrc',
116 reporter: require('jshint-stylish')
120 jshintrc: 'server/.jshintrc'
122 src: ['server/**/!(*.spec|*.integration).js']
126 jshintrc: 'server/.jshintrc-spec'
128 src: ['server/**/*.{spec,integration}.js']
130 all: ['<%= yeoman.client %>/{app,components}/**/!(*.spec|*.mock).js'],
132 src: ['<%= yeoman.client %>/{app,components}/**/*.{spec,mock}.js']
143 '<%= yeoman.client %>/app/**/*.js',
150 // Empties folders to start fresh
157 '<%= yeoman.dist %>/!(.git*|.openshift|Procfile)**'
164 // Add vendor prefixed styles
169 require('autoprefixer-core')({browsers: ['last 1 version']})
182 // Debugging with node inspector
186 'web-host': 'localhost'
191 // Use nodemon to run server in debug mode with an initial breakpoint
196 nodeArgs: ['--debug-brk'],
198 PORT: process.env.PORT || 9000
200 callback: function (nodemon) {
201 nodemon.on('log', function (event) {
202 console.log(event.colour);
205 // opens browser on initial server start
206 nodemon.on('config:update', function () {
207 setTimeout(function () {
208 require('open')('http://localhost:8080/debug?port=5858');
216 // Automatically inject Bower components into the app and karma.conf.js
225 /bootstrap-sass-official/
229 src: '<%= yeoman.client %>/index.html',
230 ignorePath: '<%= yeoman.client %>/',
233 src: './karma.conf.js',
234 devDependencies: true
238 // Renames files for browser caching purposes
242 '<%= yeoman.dist %>/client/!(bower_components){,*/}*.{js,css}',
243 // '<%= yeoman.dist %>/client/assets/images/{,*/}*.{png,jpg,jpeg,gif,webp,svg}',
244 '<%= yeoman.dist %>/client/assets/fonts/*'
249 // Reads HTML for usemin blocks to enable smart builds that automatically
250 // concat, minify and revision files. Creates configurations in memory so
251 // additional tasks can operate on them
253 html: ['<%= yeoman.client %>/index.html'],
255 dest: '<%= yeoman.dist %>/client'
259 // Performs rewrites based on rev and the useminPrepare configuration
261 html: ['<%= yeoman.dist %>/client/!(bower_components){,*/}*.html'],
262 css: ['<%= yeoman.dist %>/client/!(bower_components){,*/}*.css'],
263 js: ['<%= yeoman.dist %>/client/!(bower_components){,*/}*.js'],
266 '<%= yeoman.dist %>/client',
267 '<%= yeoman.dist %>/client/assets/images'
269 // This is so we update image references in our ng-templates
272 [/(assets\/images\/.*?\.(?:gif|jpeg|jpg|png|webp|svg))/gm, 'Update the JS to reference our revved images']
278 // The following *-min tasks produce minified files in the dist folder
283 cwd: '<%= yeoman.client %>/assets/images',
284 src: '{,*/}*.{png,jpg,jpeg,gif,svg}',
285 dest: '<%= yeoman.dist %>/client/assets/images'
290 // Allow the use of non-minsafe AngularJS files. Automatically makes it
291 // minsafe compatible so Uglify does not destroy the ng references
303 // Package all the html partials into a single javascript payload
306 // This should be the name of your apps angular module
307 module: 'dashboardApp',
309 collapseBooleanAttributes: true,
310 collapseWhitespace: true,
311 removeAttributeQuotes: true,
312 removeEmptyAttributes: true,
313 removeRedundantAttributes: true,
314 removeScriptTypeAttributes: true,
315 removeStyleLinkTypeAttributes: true
320 cwd: '<%= yeoman.client %>',
321 src: ['{app,components}/**/*.html'],
322 dest: '.tmp/templates.js'
326 src: ['{app,components}/**/*.html'],
327 dest: '.tmp/tmp-templates.js'
331 // Replace Google CDN references
334 html: ['<%= yeoman.dist %>/client/*.html']
338 // Copies remaining files to places other tasks can use
344 cwd: '<%= yeoman.client %>',
345 dest: '<%= yeoman.dist %>/client',
349 'bower_components/**/*',
350 'assets/images/{,*/}*.{webp}',
358 dest: '<%= yeoman.dist %>/client/assets/images',
362 dest: '<%= yeoman.dist %>',
371 cwd: '<%= yeoman.client %>',
373 src: ['{app,components}/**/*.css']
382 connectCommits: false,
383 message: 'Built %sourceName% from commit %sourceCommit% on branch %sourceBranch%'
399 // Run some tasks in parallel to speed up the build process
413 logConcurrentOutput: true
425 configFile: 'karma.conf.js',
433 require: 'mocha.conf.js',
434 timeout: 5000 // set default mocha spec timeout
437 src: ['server/**/*.spec.js']
440 src: ['server/**/*.integration.js']
447 excludes: ['**/*.{spec,mock,integration}.js'],
449 require: ['mocha.conf.js'],
450 mask: '**/*.spec.js',
451 coverageFolder: 'coverage/server/unit'
457 excludes: ['**/*.{spec,mock,integration}.js'],
459 require: ['mocha.conf.js'],
460 mask: '**/*.integration.js',
461 coverageFolder: 'coverage/server/integration'
467 istanbul_check_coverage: {
470 coverageFolder: 'coverage/**',
483 configFile: 'protractor.conf.js'
499 NODE_ENV: 'production'
504 // Compiles Sass to CSS
511 '.tmp/app/app.css' : '<%= yeoman.client %>/app/app.scss'
520 // Inject application script files into index.html (doesn't include bower)
523 transform: function(filePath) {
524 filePath = filePath.replace('/client/', '');
525 filePath = filePath.replace('/.tmp/', '');
526 return '<script src="' + filePath + '"></script>';
528 starttag: '<!-- injector:js -->',
529 endtag: '<!-- endinjector -->'
532 '<%= yeoman.client %>/index.html': [
534 '{.tmp,<%= yeoman.client %>}/{app,components}/**/!(*.spec|*.mock).js',
535 '!{.tmp,<%= yeoman.client %>}/app/app.js'
541 // Inject component scss into app.scss
544 transform: function(filePath) {
545 filePath = filePath.replace('/client/app/', '');
546 filePath = filePath.replace('/client/components/', '../components/');
547 return '@import \'' + filePath + '\';';
549 starttag: '// injector',
550 endtag: '// endinjector'
553 '<%= yeoman.client %>/app/app.scss': [
554 '<%= yeoman.client %>/{app,components}/**/*.{scss,sass}',
555 '!<%= yeoman.client %>/app/app.{scss,sass}'
560 // Inject component css into index.html
563 transform: function(filePath) {
564 filePath = filePath.replace('/client/', '');
565 filePath = filePath.replace('/.tmp/', '');
566 return '<link rel="stylesheet" href="' + filePath + '">';
568 starttag: '<!-- injector:css -->',
569 endtag: '<!-- endinjector -->'
572 '<%= yeoman.client %>/index.html': [
573 '<%= yeoman.client %>/{app,components}/**/*.css'
580 // Used for delaying livereload until after server has restarted
581 grunt.registerTask('wait', function () {
582 grunt.log.ok('Waiting for server reload...');
584 var done = this.async();
586 setTimeout(function () {
587 grunt.log.writeln('Done waiting!');
592 grunt.registerTask('express-keepalive', 'Keep grunt running', function() {
596 grunt.registerTask('serve', function (target) {
597 if (target === 'dist') {
598 return grunt.task.run(['build', 'env:all', 'env:prod', 'express:prod', 'wait', 'open', 'express-keepalive']);
601 if (target === 'debug') {
602 return grunt.task.run([
629 grunt.registerTask('server', function () {
630 grunt.log.warn('The `server` task has been deprecated. Use `grunt serve` to start a server.');
631 grunt.task.run(['serve']);
634 grunt.registerTask('test', function(target, option) {
635 if (target === 'server') {
636 return grunt.task.run([
640 'mochaTest:integration'
644 else if (target === 'client') {
645 return grunt.task.run([
657 else if (target === 'e2e') {
659 if (option === 'prod') {
660 return grunt.task.run([
670 return grunt.task.run([
685 else if (target === 'coverage') {
687 if (option === 'unit') {
688 return grunt.task.run([
691 'mocha_istanbul:unit'
695 else if (option === 'integration') {
696 return grunt.task.run([
699 'mocha_istanbul:integration'
703 else if (option === 'check') {
704 return grunt.task.run([
705 'istanbul_check_coverage'
710 return grunt.task.run([
714 'istanbul_check_coverage'
720 else grunt.task.run([
726 grunt.registerTask('build', [
745 grunt.registerTask('default', [