Skip to content

Commit

Permalink
grunt modifications specific to Asgard
Browse files Browse the repository at this point in the history
put grunt dist under web-app
remove cruft from index
remove unneeded yeoman files and rev grunt task
add NgController
remove unused css and image tasks
quicker html and js regeneration for grunt watch
use phantomjs rather than chrome for karma tests because it works in Jenkins
junit results for karma tests in build
  • Loading branch information
claymccoy committed Apr 17, 2014
1 parent d0666ce commit 74ee398
Show file tree
Hide file tree
Showing 17 changed files with 53 additions and 1,037 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,4 @@ test-results.xml
app/bower_components
web-app/scripts
web-app/views
coverage
182 changes: 23 additions & 159 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,38 +22,33 @@ module.exports = function (grunt) {
yeoman: {
// configurable paths
app: require('./bower.json').appPath || 'app',
dist: 'dist'
dist: 'web-app'
},

// Watches files for changes and runs tasks based on the changed files
watch: {
js: {
files: ['<%= yeoman.app %>/scripts/{,*/}*.js'],
tasks: ['newer:jshint:all'],
options: {
livereload: true
}
files: ['<%= yeoman.app %>/scripts/**/{,*/}*.js'],
tasks: ['useminPrepare',
'concat',
'copy:scripts']
},
html: {
files: ['<%= yeoman.app %>/views/**/{,*/}*.html'],
tasks: ['newer:copy:view']
},
jsTest: {
files: ['test/spec/{,*/}*.js'],
tasks: ['newer:jshint:test', 'karma']
},
styles: {
files: ['<%= yeoman.app %>/styles/{,*/}*.css'],
tasks: ['newer:copy:styles', 'autoprefixer']
},
gruntfile: {
files: ['Gruntfile.js']
},
livereload: {
options: {
livereload: '<%= connect.options.livereload %>'
},
files: [
'<%= yeoman.app %>/{,*/}*.html',
'.tmp/styles/{,*/}*.css',
'<%= yeoman.app %>/images/{,*/}*.{png,jpg,jpeg,gif,webp,svg}'
]
files: ['<%= yeoman.dist %>/**/*']
}
},

Expand Down Expand Up @@ -116,29 +111,14 @@ module.exports = function (grunt) {
dot: true,
src: [
'.tmp',
'<%= yeoman.dist %>/*',
'!<%= yeoman.dist %>/.git*'
'<%= yeoman.dist %>/scripts',
'<%= yeoman.dist %>/views'
]
}]
},
server: '.tmp'
},

// Add vendor prefixed styles
autoprefixer: {
options: {
browsers: ['last 1 version']
},
dist: {
files: [{
expand: true,
cwd: '.tmp/styles/',
src: '{,*/}*.css',
dest: '.tmp/styles/'
}]
}
},

// Automatically inject Bower components into the app
'bower-install': {
app: {
Expand All @@ -147,24 +127,6 @@ module.exports = function (grunt) {
}
},





// Renames files for browser caching purposes
rev: {
dist: {
files: {
src: [
'<%= yeoman.dist %>/scripts/{,*/}*.js',
'<%= yeoman.dist %>/styles/{,*/}*.css',
'<%= yeoman.dist %>/images/{,*/}*.{png,jpg,jpeg,gif,webp,svg}',
'<%= yeoman.dist %>/styles/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
Expand All @@ -175,36 +137,7 @@ module.exports = function (grunt) {
}
},

// Performs rewrites based on rev and the useminPrepare configuration
usemin: {
html: ['<%= yeoman.dist %>/{,*/}*.html'],
css: ['<%= yeoman.dist %>/styles/{,*/}*.css'],
options: {
assetsDirs: ['<%= yeoman.dist %>']
}
},

// The following *-min tasks produce minified files in the dist folder
imagemin: {
dist: {
files: [{
expand: true,
cwd: '<%= yeoman.app %>/images',
src: '{,*/}*.{png,jpg,jpeg,gif}',
dest: '<%= yeoman.dist %>/images'
}]
}
},
svgmin: {
dist: {
files: [{
expand: true,
cwd: '<%= yeoman.app %>/images',
src: '{,*/}*.svg',
dest: '<%= yeoman.dist %>/images'
}]
}
},
htmlmin: {
dist: {
options: {
Expand Down Expand Up @@ -235,86 +168,28 @@ module.exports = function (grunt) {
}
},

// Replace Google CDN references
cdnify: {
dist: {
html: ['<%= yeoman.dist %>/*.html']
}
},

// Copies remaining files to places other tasks can use
copy: {
dist: {
view: {
files: [{
expand: true,
dot: true,
cwd: '<%= yeoman.app %>',
dest: '<%= yeoman.dist %>',
src: [
'*.{ico,png,txt}',
'.htaccess',
'*.html',
'views/{,*/}*.html',
'bower_components/**/*',
'images/{,*/}*.{webp}',
'fonts/*'
]
}, {
expand: true,
cwd: '.tmp/images',
dest: '<%= yeoman.dist %>/images',
src: ['generated/*']
src: ['views/{,*/}*.html']
}]
},
styles: {
expand: true,
cwd: '<%= yeoman.app %>/styles',
dest: '.tmp/styles/',
src: '{,*/}*.css'
scripts: { // no minification of js used for dev mode
files: [{
expand: true,
dot: true,
cwd: '.tmp/concat',
dest: '<%= yeoman.dist %>',
src: ['scripts/scripts.js']
}]
}
},

// Run some tasks in parallel to speed up the build process
concurrent: {
server: [
'copy:styles'
],
test: [
'copy:styles'
],
dist: [
'copy:styles',
'imagemin',
'svgmin'
]
},

// By default, your `index.html`'s <!-- Usemin block --> will take care of
// minification. These next options are pre-configured if you do not wish
// to use the Usemin blocks.
// cssmin: {
// dist: {
// files: {
// '<%= yeoman.dist %>/styles/main.css': [
// '.tmp/styles/{,*/}*.css',
// '<%= yeoman.app %>/styles/{,*/}*.css'
// ]
// }
// }
// },
// uglify: {
// dist: {
// files: {
// '<%= yeoman.dist %>/scripts/scripts.js': [
// '<%= yeoman.dist %>/scripts/scripts.js'
// ]
// }
// }
// },
// concat: {
// dist: {}
// },

// Test settings
karma: {
unit: {
Expand All @@ -324,7 +199,6 @@ module.exports = function (grunt) {
}
});


grunt.registerTask('serve', function (target) {
if (target === 'dist') {
return grunt.task.run(['build', 'connect:dist:keepalive']);
Expand All @@ -333,8 +207,6 @@ module.exports = function (grunt) {
grunt.task.run([
'clean:server',
'bower-install',
'concurrent:server',
'autoprefixer',
'connect:livereload',
'watch'
]);
Expand All @@ -347,8 +219,6 @@ module.exports = function (grunt) {

grunt.registerTask('test', [
'clean:server',
'concurrent:test',
'autoprefixer',
'connect:test',
'karma'
]);
Expand All @@ -357,16 +227,10 @@ module.exports = function (grunt) {
'clean:dist',
'bower-install',
'useminPrepare',
'concurrent:dist',
'autoprefixer',
'concat',
'ngmin',
'copy:dist',
'cdnify',
'cssmin',
'copy:view',
'uglify',
'rev',
'usemin',
'htmlmin'
]);

Expand Down
Loading

0 comments on commit 74ee398

Please sign in to comment.