Skip to content

Instantly share code, notes, and snippets.

@stefanhoth
Created November 6, 2013 19:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save stefanhoth/7343057 to your computer and use it in GitHub Desktop.
Save stefanhoth/7343057 to your computer and use it in GitHub Desktop.
Grunt buildfile with angular: livereload, cssmin, jsmin all in one
{
"name": "sampleApp",
"version": "0.1.0",
"dependencies": {
"angular": "~1.2",
"angular-animate": "~1.2",
"angular-route": "~1.2",
"angular-bootstrap": "~0.6",
"bootstrap": "~3.0.0"
},
"devDependencies": {
"angular-mocks": "~1.2",
"angular-scenario": "~1.2"
}
}
module.exports = function(grunt) {
// Project configuration.
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
concat: {
js: {
src: [
'app/bower_components/angular/angular.js',
'app/bower_components/angular-route/angular-route.js',
'app/bower_components/angular-bootstrap/ui-bootstrap-tpls.js',
'app/scripts/controllers.js',
'app/scripts/app.js'
] ,
dest: 'app/dist/js/app-all.js'
},
css: {
src: [
'app/bower_components/bootstrap/dist/css/bootstrap.css',
'app/styles/main.css'
],
dest: 'app/dist/css/app-all.css'
}
},
uglify: {
js: {
src: 'app/dist/js/app-all.js',
dest: 'app/dist/js/app-all.min.js'
}
},
cssmin: {
css:{
src: 'app/dist/css/app-all.css',
dest: 'app/dist/css/app-all.min.css'
}
},
connect: {
options: {
port: 9000,
livereload: 35729,
// change this to '0.0.0.0' to access the server from outside
hostname: 'localhost'
},
livereload: {
options: {
open: true,
base: [
'.tmp',
'app'
]
}
},
test: {
options: {
base: [
'.tmp',
'test',
'app'
]
}
},
dist: {
options: {
open: true,
base: '<%= yeoman.dist %>'
}
}
},
// grunt-watch will monitor the projects files
watch: {
css:{
files: 'app/styles/*.css',
tasks: ['concat:css', 'cssmin'],
options: {
livereload: true
}
},
js:{
files: ['Gruntfile.js', 'app/scripts/*.js'],
tasks: ['concat:js', 'uglify'],
options: {
livereload: true
}
},
all: {
files: [
'app/*.html'
],
options: {
livereload: true
}
}
}
});
grunt.loadNpmTasks('grunt-contrib-concat');
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-css');
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks("grunt-contrib-connect");
grunt.registerTask('build', [
'concat',
'uglify',
'cssmin'
]);
// Default task(s).
grunt.registerTask('default', ['build']);
// Creates the `server` task
grunt.registerTask('server', [
'build',
'connect:livereload',
'watch'
]);
};
{
"name": "sampleApp",
"version": "0.1.0",
"dependencies": {},
"devDependencies": {
"grunt": "~0.4.1",
"grunt-contrib-copy": "~0.4.1",
"grunt-contrib-concat": "~0.3.0",
"grunt-contrib-uglify": "~0.2.0",
"grunt-contrib-compass": "~0.5.0",
"grunt-contrib-jshint": "~0.6.3",
"grunt-contrib-cssmin": "~0.6.0",
"grunt-contrib-connect": "~0.5.0",
"grunt-contrib-clean": "~0.5.0",
"grunt-contrib-htmlmin": "~0.1.3",
"grunt-contrib-imagemin": "~0.2.0",
"grunt-contrib-watch": "~0.5.2",
"grunt-rev": "~0.1.0",
"grunt-autoprefixer": "~0.2.0",
"grunt-usemin": "~0.1.10",
"grunt-mocha": "~0.4.0",
"grunt-modernizr": "~0.3.0",
"grunt-svgmin": "~0.2.0",
"grunt-concurrent": "~0.3.0",
"load-grunt-tasks": "~0.1.0",
"time-grunt": "~0.1.1",
"grunt-css": "~0.5.4",
"phantomjs" : "*",
"karma" : "*",
"karma-junit-reporter" : "*",
"karma-jasmine" : "*",
"karma-ng-scenario" : "*"
},
"engines": {
"node": ">=0.8.0"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment