Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ 'use strict'; module.exports = function (grunt) { // Load grunt tasks automatically require('load-grunt-tasks') (grunt); // Time how long tasks take. Can help when optimizing build times require('time-grunt') (grunt); // Define the configuration for all the tasks grunt.initConfig({ // Project settings xd: { app: 'app', dist: 'dist' }, // Set bower task's targetDir to use app directory bower: { options: { targetDir: '<%= xd.app %>/lib' }, // Provide install target install: {} }, // Watches files for changes and runs tasks based on the changed files watch: { files: ['<%= xd.app %>/ **/*', '*.js', '.jshintrc'], tasks: ['build'], livereload: { options: { livereload: '<%= connect.options.livereload %>' }, files: ['<%= xd.app %>/**/*', '*.js', '.jshintrc'] } }, protractor: { options: { //configFile: "test/ protractor.conf.js", // Default config file keepAlive: true, // If false, the grunt process stops when the test fails. noColor: false, // If true, protractor will not use colors in its output. args: { specs: [ './test/e2e/**/ *.spec.js' ], baseUrl: 'http:// localhost:8000', chromeDriver: 'node_modules/protractor/ selenium/chromedriver' } }, run: { } }, // The actual grunt server settings connect: { options: { port: 8000, // Set to '0.0.0.0' to access the server from outside. hostname: '0.0.0.0', livereload: 35729 }, livereload: { options: { open: true, base: [ '.tmp', '<%= xd.app %>' ], middleware: function (connect, options) { if (! Array.isArray(options.base)) { options.base = [options.base]; } var middlewares = [require('grunt-connect- proxy/lib/ utils').proxyRequest]; options.base.forE ach(function (base) { grunt.log.warn( base); middlewares.pus h(connect.static(base)); }); return middlewares; } } }, test: { options: { port: 9001, base: [ '.tmp', 'test', '<%= xd.app %>' ] } }, dist: { options: { base: '<%= xd.dist %>' } }, proxies: [ { context: ['/batch', '/job', '/modules', '/ streams'], host: 'localhost', port: 9393, changeOrigin: true } ] }, // Make sure code styles are up to par and there are no obvious mistakes jshint: { options: { jshintrc: '.jshintrc', reporter: require('jshint-stylish') }, all: [ 'Gruntfile.js', '<%= xd.app %>/ scripts/{,**/}*.js' ], test: { options: { jshintrc: 'test/.jshintrc' }, src: ['test/spec/ {,*/}*.js'] } }, less: { dist: { files: { '<%= xd.app %>/ styles/main.css': ['<%= xd.app %>/styles/main.less'] }, options: { sourceMap: true, sourceMapFilename: '<%= xd.app %>/styles/ main.css.map', sourceMapBasepath: '<%= xd.app %>/', sourceMapRootpath: '/' } } }, // Empties folders to start fresh clean: { dist: { files: [ { dot: true, src: [ '.tmp', '<%= xd.dist %>/*' ] } ] }, server: '.tmp' }, // Add vendor prefixed styles autoprefixer: { options: { browsers: ['last 1 version'] }, dist: { files: [ { expand: true, cwd: '.tmp/ styles/', src: '{,*/} *.css', dest: '.tmp/ styles/' } ] } }, // imagemin: { // dist: { // files: [ // { // expand: true, // cwd: '<%= xd.app %>/images', // src: '{,*/}*. {png,jpg,jpeg,gif}', // dest: '<%= xd.dist %>/images' // } // ] // } // }, // Renames files for browser caching purposes rev: { dist: { files: { src: [ // TODO: commenting out js files for now. // '<%= xd.dist %>/scripts/{,*/}*.js', '<%= xd.dist %>/ styles/{,*/}*.css', '<%= xd.dist %>/ images/{,*/}*. {png,jpg,jpeg,gif}', '<%= xd.dist %>/ fonts/*' ] } } }, // Reads HTML for usemin blocks to enable smart builds that automatically // concat, minify and revision files. Creates configurations in memory so // additional tasks can operate on them useminPrepare: { html: '<%= xd.app %>/ index.html', options: { dest: '<%= xd.dist %>' } }, // Performs rewrites based on rev and the useminPrepare configuration usemin: { html: ['<%= xd.dist %>/ {,*/}*.html'], css: ['<%= xd.dist %>/ styles/{,*/}*.css'], options: { assetsDirs: ['<%= xd.dist %>', '<%= xd.dist %>/ images'] } }, htmlmin: { dist: { options: { collapseWhitespace: true, collapseBooleanAttr ibutes: true, removeCommentsFromC DATA: true, removeOptionalTags: true }, files: [ { expand: true, cwd: '<%= xd.dist %>', src: ['*.html', 'views/{,*/}*.html'], dest: '<%= xd.dist %>' } ] } }, // Allow the use of non- minsafe AngularJS files. Automatically makes it // minsafe compatible so Uglify does not destroy the ng references // ngmin: { // dist: { // files: [ // { // expand: true, // cwd: '.tmp/ concat/js', // src: '*.js', // dest: '.tmp/ concat/js' // } // ] // } // }, // Copies remaining files to places other tasks can use copy: { dist: { files: [ { expand: true, dot: true, cwd: '<%= xd.app %>', dest: '<%= xd.dist %>', src: [ '*. {ico,png,txt}', '*.html', 'views/{,*/} *.html', 'lib/**/*', 'scripts/**/*', 'fonts/*', 'images/*' ] } ] }, styles: { expand: true, cwd: '<%= xd.app %>/ styles', dest: '.tmp/styles/', src: '{,*/}*.css' }, testfiles: { files: [ { src: 'test/ people.txt', dest: '/tmp/xd- tests/people.txt' } ] } }, // Run some tasks in parallel to speed up the build process concurrent: { server: [ 'copy:styles' ], test: [ 'copy:styles' ], dist: [ // TODO: copy:styles copies .css files into .tmp // TODO: hence probably not to include copy:styles in here. // 'copy:styles' 10 Gruntfile.js