Created
August 3, 2012 17:53
-
-
Save kalisjoshua/3249971 to your computer and use it in GitHub Desktop.
Working w/ 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
/*jshint strict:false*/ | |
/*global module*/ | |
module.exports = function(grunt) { | |
grunt.registerHelper("wrapp", function (src, argList, args) { | |
return ";(function (%1) {\n%2\n}(%3));" | |
.replace("%1", argList || "") | |
.replace("%3", args || "") | |
.replace("%2", src); | |
}); | |
grunt.registerHelper("jQuery", function (src) { | |
return grunt.helper("wrapp", src, "$", "jQuery"); | |
}); | |
grunt.initConfig({ | |
build: { | |
"dist/built": [ | |
"src/core.js", | |
"src/tables.js" | |
] | |
}, | |
jshint: { | |
options: grunt.file.readJSON("jshint.json") | |
}, | |
lint: { | |
files: ["src/**/*.js"] | |
}, | |
meta: { | |
banner: '/* <%= pkg.title || pkg.name %> - v<%= pkg.version %> */\n' | |
}, | |
pkg: '<json:raw.json>' | |
}); | |
grunt.registerMultiTask("build", "do all of the things", function () { | |
var banner = grunt.template.process(grunt.config.get("meta.banner")), | |
cat = grunt.helper("concat", this.data), | |
dist = grunt.helper("jQuery", cat), | |
ugly = grunt.helper("uglify", dist); | |
grunt.file.write(this.target + ".dbg.js", dist); | |
grunt.file.write(this.target + ".js", ugly); | |
grunt.log.writeln(grunt.template.process("\n~~ <%= pkg.title %> built successfully. ~~")); | |
}); | |
grunt.registerTask("default", "lint build"); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment