Skip to content

Instantly share code, notes, and snippets.

@kalisjoshua
Created August 3, 2012 17:53
Show Gist options
  • Save kalisjoshua/3249971 to your computer and use it in GitHub Desktop.
Save kalisjoshua/3249971 to your computer and use it in GitHub Desktop.
Working w/ Grunt
/*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