Skip to content

Instantly share code, notes, and snippets.

@jrthib
Created October 1, 2013 01:56
Show Gist options
  • Save jrthib/6772929 to your computer and use it in GitHub Desktop.
Save jrthib/6772929 to your computer and use it in GitHub Desktop.
Sample GruntFile
module.exports = function (grunt) {
grunt.loadNpmTasks('grunt-contrib-concat');
grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-contrib-clean');
grunt.loadNpmTasks('grunt-contrib-copy');
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-recess');
grunt.loadNpmTasks('grunt-karma');
grunt.loadNpmTasks('grunt-html2js');
grunt.loadNpmTasks('grunt-sass');
grunt.loadNpmTasks('grunt-reload');
// Default task.
grunt.registerTask('default', [/*'jshint',*/'build'/*, 'karma:unit'*/]);
grunt.registerTask('build', ['clean', 'concat', 'sass:dist', 'recess:build', 'copy:assets']);
grunt.registerTask('release', ['clean', 'uglify', 'jshint',/* 'karma:unit', */'concat:index', 'sass:min', 'recess:min', 'copy:assets']);
grunt.registerTask('test-watch', ['karma:watch']);
// Print a timestamp (useful for when watching)
grunt.registerTask('timestamp', function() {
grunt.log.subhead(Date());
});
var karmaConfig = function(configFile, customOptions) {
var options = { configFile: configFile, keepalive: true };
var travisOptions = process.env.TRAVIS && { browsers: ['Firefox'], reporters: 'dots' };
return grunt.util._.extend(options, customOptions, travisOptions);
};
grunt.initConfig({
distdir: 'build',
pkg: grunt.file.readJSON('package.json'),
banner:
'/*! <%= pkg.title || pkg.name %> - v<%= pkg.version %> - <%= grunt.template.today("yyyy-mm-dd") %>\n' +
'<%= pkg.homepage ? " * " + pkg.homepage + "\\n" : "" %>' +
' * Copyright (c) <%= grunt.template.today("yyyy") %> <%= pkg.author %>;\n' +
' * Licensed <%= _.pluck(pkg.licenses, "type").join(", ") %>\n */\n',
src: {
js: [
'vendor/angular/*.js',
'vendor/angular-ui/build/ui-utils.js',
'vendor/angular-ui/build/ui-utils-ieshiv.js',
'vendor/angular-bootstrap/**/*.js',
'vendor/angular-ui-router/*.js',
'src/app/**/*.js'
],
sass: ['src/app/sass/clutch.scss'],
css: [
'vendor/angular-ui/assets/css/bootstrap.css',
'vendor/angular-ui/assets/css/cssLoading.css',
'vendor/angular-ui/assets/css/prettify.css',
'vendor/angular-ui/assets/css/style.css'
],
html: ['src/**/*.html']
},
clean: ['<%= distdir %>'],
concat: {
dist: {
options: {
banner: "<%= banner %>"
},
src:['<%= src.js %>'],
dest:'<%= distdir %>/<%= pkg.name %>.js'
},
index: {
src: ['src/index.html'],
dest: '<%= distdir %>/index.html',
options: {
process: true
}
}
},
sass: {
dist: {
options: {
outputStyle: 'compact'
},
files: {
'<%= distdir %>/<%= pkg.name %>.css': ['<%= src.sass %>']
}
},
min: {
options: {
outputStyle: 'compressed'
},
files: {
'<%= distdir %>/<%= pkg.name %>.css': ['<%= src.sass %>']
}
}
},
copy: {
assets: {
files: [
{ dest: '<%= distdir %>', src : '**', expand: true, cwd: 'src/assets/' },
{ dest: '<%= distdir %>/partials/', src : '**', expand: true, cwd: 'src/app/partials/' }
]
}
},
uglify: {
dist: {
options: {
banner: "<%= banner %>"
},
src:['<%= src.js %>'],
dest:'<%= distdir %>/<%= pkg.name %>.js'
}
},
recess: {
build: {
options: {
compile: true
},
files: {
'<%= distdir %>/<%= pkg.name %>-base.css': ['<%= src.css %>']
}
},
min: {
options: {
compress: true
},
files: {
'<%= distdir %>/<%= pkg.name %>-base.css': ['<%= src.css %>']
}
}
},
jshint:{
files: ['gruntFile.js', '<%= src.js %>'],
options: {
curly: true,
eqeqeq: true,
immed: true,
latedef: true,
newcap: true,
noarg: true,
sub: true,
boss: true,
eqnull: true,
globals: {}
}
},
karma: {
unit: {
options: karmaConfig('test/config/unit.js')
},
watch: {
options: karmaConfig('test/config/unit.js',
{
singleRun: false,
autoWatch: true
})
}
},
reload: {
port: 8001,
proxy: {
host: 'dispatch.sobrioapp.com'
}
},
watch: {
all: {
files:['<%= src.js %>', '<%= src.html %>', '<%= src.sass %>', '<%= src.css %>'],
tasks:['default','timestamp']
},
//build: {
// files:['<%= src.js %>', '<%= src.html %>'],
// tasks:['build','timestamp']
//}
}
});
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment