Skip to content

Commit

Permalink
Fix for AMD when using concatenated file; fixes twbs#13812
Browse files Browse the repository at this point in the history
  • Loading branch information
hnrch02 committed Jun 18, 2014
1 parent 4582d75 commit 65dff0b
Showing 1 changed file with 19 additions and 2 deletions.
21 changes: 19 additions & 2 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@ module.exports = function (grunt) {
' */\n',
// NOTE: This jqueryCheck code is duplicated in customizer.js; if making changes here, be sure to update the other copy too.
jqueryCheck: 'if (typeof define == \'undefined\' && typeof exports == \'undefined\' && typeof jQuery == \'undefined\') { throw new Error(\'Bootstrap\\\'s JavaScript requires jQuery\') }\n\n',
umdWrap: '(function (o_o) {\n' +
' typeof define == \'function\' && define.amd ? define([\'jquery\'], o_o) :\n' +
' typeof exports == \'object\' ? o_o(require(\'jquery\')) : o_o(jQuery)\n' +
'})(function ($) {\n\n',

// Task configuration.
clean: {
Expand Down Expand Up @@ -87,8 +91,21 @@ module.exports = function (grunt) {

concat: {
options: {
banner: '<%= banner %>\n<%= jqueryCheck %>',
stripBanners: false
banner: '<%= banner %>\n<%= jqueryCheck %>\n<%= umdWrap %>',
footer: '});\n',
stripBanners: false,
process: function (src) {
var umd = '\n\n' +
' (function (o_o) {\n' +
' typeof define == \'function\' && define.amd ? define([\'jquery\'], o_o) :\n' +
' typeof exports == \'object\' ? o_o(require(\'jquery\')) : o_o(jQuery)\n' +
' })(function ($) {'

var footer = ' })\n\n' +
'}();\n'

return src.replace(umd, '').replace(footer, '}();\n')
}
},
bootstrap: {
src: [
Expand Down

0 comments on commit 65dff0b

Please sign in to comment.