From 7e8a91c205723f11cd00c8834f348a649ab15926 Mon Sep 17 00:00:00 2001 From: Timmy Willison Date: Thu, 19 Dec 2013 15:31:36 -0500 Subject: Build: add build option for setting the AMD name. Fixes #14016. --- build/tasks/build.js | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'build') diff --git a/build/tasks/build.js b/build/tasks/build.js index d4cdd1233..e5794fe93 100644 --- a/build/tasks/build.js +++ b/build/tasks/build.js @@ -42,6 +42,7 @@ module.exports = function( grunt ) { * @param {String} contents The contents to be written (including their AMD wrappers) */ function convert( name, path, contents ) { + var amdName; // Convert var modules if ( /.\/var\//.test( path ) ) { contents = contents @@ -54,6 +55,12 @@ module.exports = function( grunt ) { // Remove EXPOSE lines from Sizzle .replace( /\/\/\s*EXPOSE[\w\W]*\/\/\s*EXPOSE/, "return Sizzle;" ); + // AMD Name + } else if ( (amdName = grunt.option( "amd" )) != null && /^exports\/amd$/.test( name ) ) { + // Remove the comma for anonymous defines + contents = contents + .replace( /(\s*)"jquery"(\,\s*)/, amdName ? "$1\"" + amdName + "\"$2" : "" ); + } else { // Ignore jQuery's exports (the only necessary one) @@ -258,11 +265,11 @@ module.exports = function( grunt ) { // // grunt build:*:*:+ajax:-dimensions:-effects:-offset grunt.registerTask( "custom", function() { - var args = [].slice.call( arguments ), + var args = this.args, modules = args.length ? args[ 0 ].replace( /,/g, ":" ) : ""; grunt.log.writeln( "Creating custom build...\n" ); - grunt.task.run([ "build:*:*:" + modules, "uglify", "dist" ]); + grunt.task.run([ "build:*:*" + (modules ? ":" + modules : ""), "uglify", "dist" ]); }); }; -- cgit v1.2.3