Created
February 11, 2014 14:19
-
-
Save pantaluna/8935653 to your computer and use it in GitHub Desktop.
fcli gruntfile
This file contains hidden or 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
/*global module:false, require:false */ | |
var pause = require("grunt-pause"); | |
module.exports = function(grunt) { | |
pause.init(grunt); | |
// Project configuration. | |
grunt.initConfig({ | |
// Extra Variables | |
mjdconfig: { | |
deploydir: "_build/deploy/mjd-festival-checklist-intro/" // Format: Without leading slash, With trailing slash. | |
}, | |
pkg: | |
grunt.file.readJSON('package.json'), | |
// http://gruntjs.com/api/grunt.file | |
// http://gruntjs.com/configuring-tasks#globbing-patterns | |
// https://github.com/jharding/grunt-exec | |
exec: { | |
cd: { cmd: 'cd' }, | |
dir_files: { cmd: 'dir' }, | |
echo_grunt_version: { cmd: function() { return 'echo ' + this.version; } }, | |
multiple_commands: { command: ['cd','dir'].join('&&') }, | |
prepare_build: { | |
cwd: '_build', | |
cmd: 'preparebuild.cmd' | |
}, | |
}, | |
// https://github.com/gruntjs/grunt-contrib-jshint | |
jshint: { | |
options: { | |
'-W079': true, // W079: Redefinition of ('console' in my error report) | |
'-W099': true, // W099: Mixed spaces and tabs. | |
curly: true, | |
//eqeqeq: true, | |
latedef: true, | |
newcap: false, | |
trailing: false, | |
undef: true, | |
laxcomma: true, | |
smarttabs: true, | |
sub: true, | |
browser: true, | |
devel: true, | |
jquery: true, | |
node: true, | |
nonstandard: true, | |
globals: { | |
"_gaq": false, | |
'ActiveXObject': false, | |
'Back': false, | |
'changeStatus': false, | |
'cbpAnimatedHeader': false, | |
'cbpScroller': false, | |
'createElement': false, | |
'DOMParse': false, | |
'GetObject': false, | |
'NProgress': false, | |
'TimelineMax': false, | |
} | |
}, | |
dev: { | |
src: [ | |
'Gruntfile.js', | |
'js/ga.js', | |
'js/lib-mjd-core.js', | |
'js/loader.js', | |
'js/myview-mgr.js', | |
] | |
} | |
}, | |
// https://github.com/gruntjs/grunt-contrib-compass | |
compass: { | |
dev: { | |
options: { | |
config: 'config.rb', // point to the config that is also used by my Gumby development environment. | |
} | |
} | |
}, | |
// https://github.com/gruntjs/grunt-contrib-clean | |
clean: { | |
build: ['<%= mjdconfig.deploydir %>'], | |
}, | |
// hhttps://github.com/gruntjs/grunt-contrib-htmlmin | |
htmlmin: { | |
build: { | |
options: { | |
removeComments: true | |
}, | |
files: { | |
'<%= mjdconfig.deploydir %>index.html': | |
'<%= mjdconfig.deploydir %>index.html' | |
} | |
} | |
}, | |
// https://github.com/gruntjs/grunt-contrib-uglify | |
uglify_example_specific_files: { | |
build: { | |
options: { | |
banner: '/*! MJD Uglify <%= grunt.template.today("yyyy-mm-dd") %> */\n', | |
compress: { | |
unused: false, | |
}, | |
mangle: false, | |
report: 'min', | |
}, | |
files: [ | |
{src:'<%= mjdconfig.deploydir %>js/ga.js', dest:'<%= mjdconfig.deploydir %>js/ga.min.js'} | |
] | |
} | |
}, | |
uglify: { | |
build: { | |
options: { | |
banner: '/*! MJD Uglify <%= grunt.template.today("yyyy-mm-dd") %> */\n', | |
compress: { | |
unused: false, | |
}, | |
mangle: true, // 1. Mangle AFTER Compress. | 2. If the mangled JS does not work anymore Then set mangle=false! | |
report: 'min', | |
}, | |
files: [ | |
{ | |
expand: true, | |
cwd: '<%= mjdconfig.deploydir %>', | |
src:['js/**/*.js','!**/*.min.js'], | |
dest:'<%= mjdconfig.deploydir %>', | |
ext: '.min.js', | |
}, | |
] | |
} | |
}, | |
uglify_post_delete_sources: { | |
build: { | |
files: [ | |
{ | |
expand: true, | |
cwd: '<%= mjdconfig.deploydir %>', | |
src:['js/**/*.js','!**/*.min.js'], | |
dest:'<%= mjdconfig.deploydir %>', // This line has no effect, it is a duplicate of the uglify section. | |
ext: '.min.js', | |
}, | |
] | |
} | |
}, | |
cssmin: { | |
build: { | |
options: { | |
banner: '/*! MJD cssmin <%= grunt.template.today("yyyy-mm-dd") %> */\n', | |
compress: { | |
unused: false, | |
}, | |
report: 'min', | |
}, | |
files: [ | |
{ | |
expand: true, | |
cwd: '<%= mjdconfig.deploydir %>', | |
src:['css/**/*.css','!**/*.min.css'], | |
dest:'<%= mjdconfig.deploydir %>', | |
ext: '.min.css', | |
}, | |
] | |
} | |
}, | |
cssmin_post_delete_sources: { | |
build: { | |
files: [ | |
{ | |
expand: true, | |
cwd: '<%= mjdconfig.deploydir %>', | |
src:['css/**/*.css','!**/*.min.css'], | |
dest:'<%= mjdconfig.deploydir %>', // This line has no effect, it is a duplicate of the cssmin section. | |
ext: '.min.css', | |
}, | |
] | |
} | |
}, | |
replace: { | |
indexhtml: { | |
overwrite: true, | |
src: ['<%= mjdconfig.deploydir %>index.html'], | |
replacements: [ | |
// JS | |
{from: 'js/loader.js', to: 'js/loader.min.js'}, | |
// CSS | |
{from: 'css/cbp-animated-header/component.css', to: 'css/cbp-animated-header/component.min.css'}, | |
{from: 'css/cbp-scroller/component.css', to: 'css/cbp-scroller/component.min.css'}, | |
{from: 'css/gumby.css', to: 'css/gumby.min.css'}, | |
{from: 'css/nprogress/component.css', to: 'css/nprogress/component.min.css'}, | |
{from: 'css/responsiveslides/responsiveslides.css', to: 'css/responsiveslides/responsiveslides.min.css'}, | |
], | |
}, | |
loaderminjs: { | |
overwrite: true, | |
src: ['<%= mjdconfig.deploydir %>js/loader.min.js'], | |
replacements: [ | |
// SPECIALS | |
{from: 'strEnvironmentType:mjdApp.myConstants.environmentType.DEVELOPMENT', | |
to: 'strEnvironmentType:mjdApp.myConstants.environmentType.PRODUCTION' | |
}, | |
// CSS | |
// JS | |
{from: 'js/cbp-animated-header/component.js', to: 'js/cbp-animated-header/component.min.js'}, | |
{from: 'js/cbp-scroller/classie.js', to: 'js/cbp-scroller/classie.min.js'}, | |
{from: 'js/cbp-scroller/component.js', to: 'js/cbp-scroller/component.min.js'}, | |
{from: 'js/ga.js', to: 'js/ga.min.js'}, | |
{from: 'js/lib-mjd-core.js', to: 'js/lib-mjd-core.min.js'}, | |
{from: 'js/myview-mgr.js', to: 'js/myview-mgr.min.js'}, | |
{from: 'js/nprogress/component.js', to: 'js/nprogress/component.min.js'}, | |
] | |
} | |
} | |
}); | |
// Load Grunt plugins. | |
grunt.loadNpmTasks('grunt-exec'); | |
grunt.loadNpmTasks('grunt-contrib-clean'); | |
grunt.loadNpmTasks('grunt-contrib-compass'); | |
grunt.loadNpmTasks('grunt-contrib-copy'); | |
grunt.loadNpmTasks('grunt-contrib-cssmin'); | |
grunt.loadNpmTasks('grunt-contrib-htmlmin'); | |
grunt.loadNpmTasks('grunt-contrib-jshint'); | |
grunt.loadNpmTasks('grunt-contrib-uglify'); | |
grunt.loadNpmTasks('grunt-text-replace'); | |
// Define my custom tasks | |
grunt.registerMultiTask("uglify_post_delete_sources", "JS Uglify - Post Actions", function() { | |
//grunt.log.writeln([this.name,this.target]); | |
this.files.forEach( function(pOneFileItem) { | |
grunt.file.delete(pOneFileItem.src); | |
grunt.log.writeln('Executing grunt.file.delete ' + pOneFileItem.src); | |
}); | |
}); | |
grunt.registerMultiTask("cssmin_post_delete_sources", "CSSmin - Post Actions", function() { | |
//grunt.log.writeln([this.name,this.target]); | |
this.files.forEach( function(pOneFileItem) { | |
grunt.file.delete(pOneFileItem.src); | |
grunt.log.writeln('Executing grunt.file.delete ' + pOneFileItem.src); | |
}); | |
}); | |
// Register the default tasks. | |
grunt.registerTask('default',[ | |
'jshint:dev','compass:dev', | |
'clean:build','exec:prepare_build', | |
'htmlmin:build', | |
'uglify:build','uglify_post_delete_sources:build', | |
'cssmin:build','cssmin_post_delete_sources:build', | |
'replace:indexhtml','replace:loaderminjs' | |
]); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment