Created
April 3, 2014 18:26
-
-
Save dtothefp/9959992 to your computer and use it in GitHub Desktop.
angular production grunt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module.exports = function(grunt) { | |
// Project configuration. | |
grunt.initConfig({ | |
pkg: grunt.file.readJSON('package.json'), | |
files: { | |
desktopSrc: ['public/js/config/*.js', 'public/js/factories/*.js', 'public/js/controllers/*.js', 'public/js/directives/*.js'], | |
mobileSrc: ['public_mobile/js/config/*.js', 'public_mobile/js/factories/*.js', 'public_mobile/js/controllers/*.js', 'public_mobile/js/directives/*.js'], | |
desktopImg: ['public/images/{,**/}*.{jpg,png,gif}', 'public/video/**/{,**/}*.{jpg,png,gif}'], | |
mobileImg: ['public_mobile/images/{,**/}*.{jpg,png,gif}'] | |
}, | |
express: { | |
options: { | |
// Override defaults here | |
}, | |
dev: { | |
options: { | |
script: 'app.js' | |
} | |
} | |
}, | |
concat: { | |
dev: { | |
files: { | |
'public/.tmp/main.js': ['<%= files.desktopSrc %>'], | |
'public_mobile/.tmp/main.js': ['<%= files.mobileSrc %>'] | |
} | |
}, | |
}, | |
ngmin: { | |
desktop: { | |
src: ['public/.tmp/*.js'], | |
dest: 'public/build/main.js' | |
}, | |
mobile: { | |
src: ['public_mobile/.tmp/*.js'], | |
dest: 'public_mobile/build/main.js' | |
} | |
}, | |
watch: { | |
scripts: { | |
files: ['public/js/**/*.js', 'public_mobile/js/**/*.js'], | |
tasks: ['concat', 'ngmin'] | |
} | |
}, | |
// Production Tasks | |
//DESKTOP | |
// useminPrepare: { | |
// html: 'public/index.html', | |
// options: { | |
// dest: 'build' | |
// // flow: { | |
// // html: { | |
// // steps: {'js': ['concat:prod', 'uglifyjs']}, | |
// // post: {} | |
// // } | |
// // } | |
// } | |
// }, | |
// usemin: { | |
// html: ['build/index.html'] | |
// }, | |
//MOBILE | |
useminPrepare: { | |
html: 'public_mobile/index.html', | |
options: { | |
dest: 'build_mobile' | |
// flow: { | |
// html: { | |
// steps: {'js': ['concat:prod', 'uglifyjs']}, | |
// post: {} | |
// } | |
// } | |
} | |
}, | |
usemin: { | |
html: ['build_mobile/index.html'] | |
}, | |
copy: { | |
desktop: { | |
expand: true, | |
cwd: 'public/', | |
src: ['**','js/templates/**', '!css/**','!**/*.css', '!bower_components/**', 'images/**', '!stylesheets/**', '!build/**', 'video/**', 'js/vendor/jquery-1.10.1.min.js', 'js/vendor/angular.min.js'], | |
dest: 'build/' | |
}, | |
mobile: { | |
expand: true, | |
cwd: 'public_mobile/', | |
src: ['**', '!js/**', '!css/**','!**/*.css', '!bower_components/**', 'images/**', '!stylesheets/**', '!build/**', 'video/**'], | |
dest: 'build_mobile/' | |
} | |
// shims: { | |
// expand: true, | |
// cwd: 'public/bower_components/webshim/js-webshim/dev/shims/', | |
// src: ['**'], | |
// dest: 'build/js/shims' | |
// } | |
}, | |
uglify: { | |
options: { | |
report: 'min', | |
mangle: false | |
} | |
}, | |
cssmin: { | |
// files: { | |
// 'build/css/': ['.tmp/concat/css/main.css'] | |
// } | |
}, | |
rev: { | |
desktop: { | |
src: ['build/js/*.js', 'build/css/*.css'] | |
}, | |
mobile: { | |
src: ['build_mobile/js/*.{js,css}', 'build_mobile/css/*.{js,css}'] | |
} | |
}, | |
imagemin: { | |
options: { // Target options | |
optimizationLevel: 3 | |
}, // Task | |
desktop: { // Target | |
files: { // Dictionary of files | |
'build': ['<%= files.desktopImg %>'] // 'destination': 'source' | |
} | |
}, | |
mobile: { // Another target | |
files: [{ | |
expand: true, // Enable dynamic expansion | |
cwd: './', // Src matches are relative to this path | |
src: ['<%= files.mobileImg %>'], // Actual patterns to match | |
dest: 'build_mobile/' // Destination path prefix | |
}] | |
} | |
}, | |
clean: { | |
desktop: ['build', '.tmp'], | |
mobile: ['build_mobile', '.tmp'] | |
} | |
}); | |
// Load the plugin that provides the "uglify" task. | |
grunt.loadNpmTasks('grunt-contrib-uglify'); | |
grunt.loadNpmTasks('grunt-contrib-concat'); | |
grunt.loadNpmTasks('grunt-contrib-watch'); | |
grunt.loadNpmTasks('grunt-express-server'); | |
grunt.loadNpmTasks('grunt-contrib-coffee'); | |
grunt.loadNpmTasks('grunt-contrib-clean'); | |
grunt.loadNpmTasks('grunt-rev'); | |
grunt.loadNpmTasks('grunt-contrib-cssmin'); | |
grunt.loadNpmTasks('grunt-contrib-jshint'); | |
grunt.loadNpmTasks('grunt-contrib-copy'); | |
grunt.loadNpmTasks('grunt-usemin'); | |
grunt.loadNpmTasks('grunt-filerev'); | |
grunt.loadNpmTasks('grunt-ngmin'); | |
grunt.loadNpmTasks('grunt-contrib-imagemin'); | |
grunt.loadNpmTasks('grunt-filerev'); | |
// Default task(s). | |
grunt.registerTask('default', ['express:dev', 'watch']); | |
grunt.registerTask('pre', ['concat', 'ngmin']); | |
grunt.registerTask('buildDesktop', [ | |
'clean:desktop', 'pre', 'copy:desktop', 'useminPrepare', 'concat', 'uglify', 'cssmin', 'rev', 'usemin' | |
]); | |
grunt.registerTask('buildMobile', [ | |
'clean:mobile', 'pre', 'copy:mobile', 'useminPrepare', 'concat', 'uglify', 'cssmin', 'rev', 'usemin' | |
]); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment