UNPKG

generator-booang

Version:

Latest Angular and Boostrap generator. Based on the MEAN stack generator for Yeoman. Angular 1.2.0-rc.2 and Bootstrap 3

321 lines (309 loc) 7.2 kB
// Generated on 2013-07-11 using generator-angular 0.3.0 'use strict'; var LIVERELOAD_PORT = 35729; var path = require('path'); // # Globbing // for performance reasons we're only matching one level down: // 'test/spec/{,*/}*.js' // use this if you want to recursively match all subfolders: // 'test/spec/**/*.js' module.exports = function (grunt) { // load all grunt tasks // require('matchdep').filterDev('grunt-*').forEach(grunt.loadNpmTasks); require('load-grunt-tasks')(grunt); require('time-grunt')(grunt); // configurable paths var yeomanConfig = { app: 'app', dist: 'dist' }; try { yeomanConfig.app = require('./bower.json').appPath || yeomanConfig.app; } catch (e) {} grunt.loadNpmTasks('grunt-express'); grunt.initConfig({ yeoman: yeomanConfig, watch: { coffee: { files: ['<%= yeoman.app %>/js/{,*/}*.coffee'], tasks: ['coffee:dist'] }, coffeeTest: { files: ['test/spec/{,*/}*.coffee'], tasks: ['coffee:test'] }, livereload: { options: { livereload: LIVERELOAD_PORT }, files: [ '<%= yeoman.app %>/{,*/}*.html', '{.tmp,<%= yeoman.app %>}/css/{,*/}*.css', '{.tmp,<%= yeoman.app %>}/js/{,*/}*.js', '<%= yeoman.app %>/img/{,*/}*.{png,jpg,jpeg,gif,webp,svg}' ] } }, express: { options: { port: 3000, hostname: '*' }, livereload: { options: { livereload: true, server: path.resolve('app.js'), bases: [path.resolve('./.tmp'), path.resolve(__dirname, yeomanConfig.app)] } }, test: { options: { server: path.resolve('app.js'), bases: [path.resolve('./.tmp'), path.resolve(__dirname, 'test')] } }, dist: { options: { server: path.resolve('app.js'), bases: path.resolve(__dirname, yeomanConfig.dist) } } }, open: { server: { url: 'http://localhost:<%= express.options.port %>' } }, clean: { dist: { files: [{ dot: true, src: [ '.tmp', '<%= yeoman.dist %>/*', '!<%= yeoman.dist %>/.git*' ] }] }, server: '.tmp' }, jshint: { options: { jshintrc: '.jshintrc' }, all: [ 'Gruntfile.js', '<%= yeoman.app %>/js/{,*/}*.js' ] }, coffee: { dist: { files: [{ expand: true, cwd: '<%= yeoman.app %>/js', src: '{,*/}*.coffee', dest: '.tmp/js', ext: '.js' }] }, test: { files: [{ expand: true, cwd: 'test/spec', src: '{,*/}*.coffee', dest: '.tmp/spec', ext: '.js' }] } }, // not used since Uglify task does concat, // but still available if needed /*concat: { dist: {} },*/ rev: { dist: { files: { src: [ '<%= yeoman.dist %>/js/{,*/}*.js', '<%= yeoman.dist %>/css/{,*/}*.css', '<%= yeoman.dist %>/img/{,*/}*.{png,jpg,jpeg,gif,webp,svg}', '<%= yeoman.dist %>/fonts/*' ] } } }, useminPrepare: { html: '<%= yeoman.app %>/index.html', options: { dest: '<%= yeoman.dist %>' } }, usemin: { html: ['<%= yeoman.dist %>/{,*/}*.html'], css: ['<%= yeoman.dist %>/css/{,*/}*.css'], options: { dirs: ['<%= yeoman.dist %>'] } }, imagemin: { dist: { files: [{ expand: true, cwd: '<%= yeoman.app %>/img', src: '{,*/}*.{png,jpg,jpeg}', dest: '<%= yeoman.dist %>/img' }] } }, svgmin: { dist: { files: [{ expand: true, cwd: '<%%= yeoman.app %>/img', src: '{,*/}*.svg', dest: '<%%= yeoman.dist %>/img' }] } }, cssmin: { // By default, your `index.html` <!-- Usemin Block --> will take care of // minification. This option is pre-configured if you do not wish to use // Usemin blocks. // dist: { // files: { // '<%= yeoman.dist %>/styles/main.css': [ // '.tmp/styles/{,*/}*.css', // '<%= yeoman.app %>/styles/{,*/}*.css' // ] // } // } }, htmlmin: { dist: { options: { /*removeCommentsFromCDATA: true, // https://github.com/yeoman/grunt-usemin/issues/44 //collapseWhitespace: true, collapseBooleanAttributes: true, removeAttributeQuotes: true, removeRedundantAttributes: true, useShortDoctype: true, removeEmptyAttributes: true, removeOptionalTags: true*/ }, files: [{ expand: true, cwd: '<%= yeoman.app %>', src: ['*.html', 'partials/*.html'], dest: '<%= yeoman.dist %>' }] } }, // Put files not handled in other tasks here copy: { dist: { files: [{ expand: true, dot: true, cwd: '<%= yeoman.app %>', dest: '<%= yeoman.dist %>', src: [ '*.{ico,png,txt}', '.htaccess', 'libs/**/*', 'img/{,*/}*.{gif,webp,svg}', 'fonts/*' ] }, { expand: true, cwd: '.tmp/img', dest: '<%= yeoman.dist %>/img', src: [ 'generated/*' ] }] } }, concurrent: { server: [ 'coffee:dist' ], test: [ 'coffee' ], dist: [ 'coffee', 'imagemin', 'htmlmin', ] }, karma: { unit: { configFile: 'karma.conf.js', singleRun: true } }, cdnify: { dist: { html: ['<%= yeoman.dist %>/*.html'] } }, ngmin: { dist: { files: [{ expand: true, cwd: '<%= yeoman.dist %>/js', src: '*.js', dest: '<%= yeoman.dist %>/scripts' }] } }, uglify: { dist: { files: { '<%= yeoman.dist %>/scripts/scripts.js': [ '<%= yeoman.dist %>/scripts/scripts.js' ] } } } }); grunt.registerTask('server', function (target) { if (target === 'dist') { return grunt.task.run(['build', 'open', 'express:dist', 'express-keepalive']); } grunt.task.run([ 'clean:server', 'concurrent:server', 'express:livereload', 'open', 'watch' ]); }); grunt.registerTask('test', [ 'clean:server', 'concurrent:test', 'express:test', 'karma', 'jshint' ]); grunt.registerTask('build', [ 'clean:dist', 'useminPrepare', 'concurrent:dist', 'concat', 'copy:dist', 'cdnify', 'ngmin', 'cssmin', 'uglify', 'rev', 'usemin' ]); grunt.registerTask('default', [ 'jshint', 'test', 'build' ]); };