summaryrefslogtreecommitdiffstats
path: root/bower_components/bootstrap/Gruntfile.js
diff options
context:
space:
mode:
Diffstat (limited to 'bower_components/bootstrap/Gruntfile.js')
-rw-r--r--bower_components/bootstrap/Gruntfile.js275
1 files changed, 163 insertions, 112 deletions
diff --git a/bower_components/bootstrap/Gruntfile.js b/bower_components/bootstrap/Gruntfile.js
index 66e1de3..4c021ce 100644
--- a/bower_components/bootstrap/Gruntfile.js
+++ b/bower_components/bootstrap/Gruntfile.js
@@ -1,7 +1,7 @@
/*!
* Bootstrap's Gruntfile
* http://getbootstrap.com
- * Copyright 2013-2014 Twitter, Inc.
+ * Copyright 2013-2015 Twitter, Inc.
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
*/
@@ -20,7 +20,21 @@ module.exports = function (grunt) {
var npmShrinkwrap = require('npm-shrinkwrap');
var generateGlyphiconsData = require('./grunt/bs-glyphicons-data-generator.js');
var BsLessdocParser = require('./grunt/bs-lessdoc-parser.js');
+ var getLessVarsData = function () {
+ var filePath = path.join(__dirname, 'less/variables.less');
+ var fileContent = fs.readFileSync(filePath, { encoding: 'utf8' });
+ var parser = new BsLessdocParser(fileContent);
+ return { sections: parser.parseFile() };
+ };
var generateRawFiles = require('./grunt/bs-raw-files-generator.js');
+ var generateCommonJSModule = require('./grunt/bs-commonjs-generator.js');
+ var configBridge = grunt.file.readJSON('./grunt/configBridge.json', { encoding: 'utf8' });
+
+ Object.keys(configBridge.paths).forEach(function (key) {
+ configBridge.paths[key].forEach(function (val, i, arr) {
+ arr[i] = path.join('./docs/assets', val);
+ });
+ });
// Project configuration.
grunt.initConfig({
@@ -30,14 +44,15 @@ module.exports = function (grunt) {
banner: '/*!\n' +
' * Bootstrap v<%= pkg.version %> (<%= pkg.homepage %>)\n' +
' * Copyright 2011-<%= grunt.template.today("yyyy") %> <%= pkg.author %>\n' +
- ' * Licensed under <%= pkg.license.type %> (<%= pkg.license.url %>)\n' +
+ ' * Licensed under the <%= pkg.license %> license\n' +
' */\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 jQuery === \'undefined\') { throw new Error(\'Bootstrap\\\'s JavaScript requires jQuery\') }\n\n',
+ jqueryCheck: configBridge.config.jqueryCheck.join('\n'),
+ jqueryVersionCheck: configBridge.config.jqueryVersionCheck.join('\n'),
// Task configuration.
clean: {
- dist: ['dist', 'docs/dist']
+ dist: 'dist',
+ docs: 'docs/dist'
},
jshint: {
@@ -48,9 +63,9 @@ module.exports = function (grunt) {
options: {
jshintrc: 'grunt/.jshintrc'
},
- src: ['Gruntfile.js', 'grunt/*.js']
+ src: ['Gruntfile.js', 'package.js', 'grunt/*.js']
},
- src: {
+ core: {
src: 'js/*.js'
},
test: {
@@ -60,7 +75,7 @@ module.exports = function (grunt) {
src: 'js/tests/unit/*.js'
},
assets: {
- src: ['docs/assets/js/_src/*.js', 'docs/assets/js/*.js', '!docs/assets/js/*.min.js']
+ src: ['docs/assets/js/src/*.js', 'docs/assets/js/*.js', '!docs/assets/js/*.min.js']
}
},
@@ -71,8 +86,8 @@ module.exports = function (grunt) {
grunt: {
src: '<%= jshint.grunt.src %>'
},
- src: {
- src: '<%= jshint.src.src %>'
+ core: {
+ src: '<%= jshint.core.src %>'
},
test: {
src: '<%= jshint.test.src %>'
@@ -87,7 +102,7 @@ module.exports = function (grunt) {
concat: {
options: {
- banner: '<%= banner %>\n<%= jqueryCheck %>',
+ banner: '<%= banner %>\n<%= jqueryCheck %>\n<%= jqueryVersionCheck %>',
stripBanners: false
},
bootstrap: {
@@ -111,30 +126,22 @@ module.exports = function (grunt) {
uglify: {
options: {
+ compress: {
+ warnings: false
+ },
+ mangle: true,
preserveComments: 'some'
},
- bootstrap: {
+ core: {
src: '<%= concat.bootstrap.dest %>',
dest: 'dist/js/<%= pkg.name %>.min.js'
},
customize: {
- src: [
- 'docs/assets/js/_vendor/less.min.js',
- 'docs/assets/js/_vendor/jszip.min.js',
- 'docs/assets/js/_vendor/uglify.min.js',
- 'docs/assets/js/_vendor/blob.js',
- 'docs/assets/js/_vendor/filesaver.js',
- 'docs/assets/js/raw-files.min.js',
- 'docs/assets/js/_src/customizer.js'
- ],
+ src: configBridge.paths.customizerJs,
dest: 'docs/assets/js/customize.min.js'
},
docsJs: {
- src: [
- 'docs/assets/js/_vendor/holder.js',
- 'docs/assets/js/_vendor/ZeroClipboard.min.js',
- 'docs/assets/js/_src/application.js'
- ],
+ src: configBridge.paths.docsJs,
dest: 'docs/assets/js/docs.min.js'
}
},
@@ -155,9 +162,8 @@ module.exports = function (grunt) {
sourceMapURL: '<%= pkg.name %>.css.map',
sourceMapFilename: 'dist/css/<%= pkg.name %>.css.map'
},
- files: {
- 'dist/css/<%= pkg.name %>.css': 'less/bootstrap.less'
- }
+ src: 'less/bootstrap.less',
+ dest: 'dist/css/<%= pkg.name %>.css'
},
compileTheme: {
options: {
@@ -167,24 +173,14 @@ module.exports = function (grunt) {
sourceMapURL: '<%= pkg.name %>-theme.css.map',
sourceMapFilename: 'dist/css/<%= pkg.name %>-theme.css.map'
},
- files: {
- 'dist/css/<%= pkg.name %>-theme.css': 'less/theme.less'
- }
+ src: 'less/theme.less',
+ dest: 'dist/css/<%= pkg.name %>-theme.css'
}
},
autoprefixer: {
options: {
- browsers: [
- 'Android 2.3',
- 'Android >= 4',
- 'Chrome >= 20',
- 'Firefox >= 24', // Firefox 24 is the latest ESR
- 'Explorer >= 8',
- 'iOS >= 6',
- 'Opera >= 12',
- 'Safari >= 6'
- ]
+ browsers: configBridge.config.autoprefixerBrowsers
},
core: {
options: {
@@ -199,7 +195,7 @@ module.exports = function (grunt) {
src: 'dist/css/<%= pkg.name %>-theme.css'
},
docs: {
- src: 'docs/assets/css/_src/docs.css'
+ src: ['docs/assets/css/src/docs.css']
},
examples: {
expand: true,
@@ -213,7 +209,7 @@ module.exports = function (grunt) {
options: {
csslintrc: 'less/.csslintrc'
},
- src: [
+ dist: [
'dist/css/bootstrap.css',
'dist/css/bootstrap-theme.css'
],
@@ -225,41 +221,35 @@ module.exports = function (grunt) {
ids: false,
'overqualified-elements': false
},
- src: 'docs/assets/css/_src/docs.css'
+ src: 'docs/assets/css/src/docs.css'
}
},
cssmin: {
options: {
+ // TODO: disable `zeroUnits` optimization once clean-css 3.2 is released
+ // and then simplify the fix for https://github.com/twbs/bootstrap/issues/14837 accordingly
compatibility: 'ie8',
keepSpecialComments: '*',
- noAdvanced: true
+ advanced: false
},
- core: {
- files: {
- 'dist/css/<%= pkg.name %>.min.css': 'dist/css/<%= pkg.name %>.css',
- 'dist/css/<%= pkg.name %>-theme.min.css': 'dist/css/<%= pkg.name %>-theme.css'
- }
+ minifyCore: {
+ src: 'dist/css/<%= pkg.name %>.css',
+ dest: 'dist/css/<%= pkg.name %>.min.css'
+ },
+ minifyTheme: {
+ src: 'dist/css/<%= pkg.name %>-theme.css',
+ dest: 'dist/css/<%= pkg.name %>-theme.min.css'
},
docs: {
src: [
- 'docs/assets/css/_src/docs.css',
- 'docs/assets/css/_src/pygments-manni.css'
+ 'docs/assets/css/src/pygments-manni.css',
+ 'docs/assets/css/src/docs.css'
],
dest: 'docs/assets/css/docs.min.css'
}
},
- usebanner: {
- options: {
- position: 'top',
- banner: '<%= banner %>'
- },
- files: {
- src: 'dist/css/*.css'
- }
- },
-
csscomb: {
options: {
config: 'less/.csscomb.json'
@@ -277,9 +267,8 @@ module.exports = function (grunt) {
dest: 'docs/examples/'
},
docs: {
- files: {
- 'docs/assets/css/_src/docs.css': 'docs/assets/css/_src/docs.css'
- }
+ src: 'docs/assets/css/src/docs.css',
+ dest: 'docs/assets/css/src/docs.css'
}
},
@@ -291,13 +280,11 @@ module.exports = function (grunt) {
},
docs: {
expand: true,
- cwd: './dist',
+ cwd: 'dist/',
src: [
- '{css,js}/*.min.*',
- 'css/*.map',
- 'fonts/*'
+ '**/*'
],
- dest: 'docs/dist'
+ dest: 'docs/dist/'
}
},
@@ -311,54 +298,74 @@ module.exports = function (grunt) {
},
jekyll: {
- docs: {}
+ options: {
+ config: '_config.yml'
+ },
+ docs: {},
+ github: {
+ options: {
+ raw: 'github: true'
+ }
+ }
},
- jade: {
- compile: {
+ htmlmin: {
+ dist: {
options: {
- pretty: true,
- data: function () {
- var filePath = path.join(__dirname, 'less/variables.less');
- var fileContent = fs.readFileSync(filePath, { encoding: 'utf8' });
- var parser = new BsLessdocParser(fileContent);
- return { sections: parser.parseFile() };
- }
+ collapseWhitespace: true,
+ conservativeCollapse: true,
+ minifyCSS: true,
+ minifyJS: true,
+ removeAttributeQuotes: true,
+ removeComments: true
},
- files: {
- 'docs/_includes/customizer-variables.html': 'docs/_jade/customizer-variables.jade',
- 'docs/_includes/nav/customize.html': 'docs/_jade/customizer-nav.jade'
- }
+ expand: true,
+ cwd: '_gh_pages',
+ dest: '_gh_pages',
+ src: [
+ '**/*.html',
+ '!examples/**/*.html'
+ ]
}
},
- validation: {
+ jade: {
options: {
- charset: 'utf-8',
- doctype: 'HTML5',
- failHard: true,
- reset: true,
- relaxerror: [
- 'Bad value X-UA-Compatible for attribute http-equiv on element meta.',
- 'Element img is missing required attribute src.'
- ]
+ pretty: true,
+ data: getLessVarsData
},
- files: {
- src: '_gh_pages/**/*.html'
+ customizerVars: {
+ src: 'docs/_jade/customizer-variables.jade',
+ dest: 'docs/_includes/customizer-variables.html'
+ },
+ customizerNav: {
+ src: 'docs/_jade/customizer-nav.jade',
+ dest: 'docs/_includes/nav/customize.html'
}
},
+ htmllint: {
+ options: {
+ ignore: [
+ 'Attribute "autocomplete" not allowed on element "button" at this point.',
+ 'Attribute "autocomplete" not allowed on element "input" at this point.',
+ 'Element "img" is missing required attribute "src".'
+ ]
+ },
+ src: '_gh_pages/**/*.html'
+ },
+
watch: {
src: {
- files: '<%= jshint.src.src %>',
- tasks: ['jshint:src', 'qunit']
+ files: '<%= jshint.core.src %>',
+ tasks: ['jshint:core', 'qunit', 'concat']
},
test: {
files: '<%= jshint.test.src %>',
tasks: ['jshint:test', 'qunit']
},
less: {
- files: 'less/*.less',
+ files: 'less/**/*.less',
tasks: 'less'
}
},
@@ -370,6 +377,14 @@ module.exports = function (grunt) {
return old ? RegExp.quote(old) : old;
})(),
replacement: grunt.option('newver'),
+ exclude: [
+ 'dist/fonts',
+ 'docs/assets',
+ 'fonts',
+ 'js/tests/vendor',
+ 'node_modules',
+ 'test-infra'
+ ],
recursive: true
}
},
@@ -378,9 +393,10 @@ module.exports = function (grunt) {
all: {
options: {
build: process.env.TRAVIS_JOB_ID,
- concurrency: 10,
+ throttled: 10,
maxRetries: 3,
- urls: ['http://127.0.0.1:3000/js/tests/index.html'],
+ maxPollRetries: 4,
+ urls: ['http://127.0.0.1:3000/js/tests/index.html?hidepassed'],
browsers: grunt.file.readYAML('grunt/sauce_browsers.yml')
}
}
@@ -390,7 +406,27 @@ module.exports = function (grunt) {
npmUpdate: {
command: 'npm update'
}
+ },
+
+ compress: {
+ main: {
+ options: {
+ archive: 'bootstrap-<%= pkg.version %>-dist.zip',
+ mode: 'zip',
+ level: 9,
+ pretty: true
+ },
+ files: [
+ {
+ expand: true,
+ cwd: 'dist/',
+ src: ['**'],
+ dest: 'bootstrap-<%= pkg.version %>-dist'
+ }
+ ]
+ }
}
+
});
@@ -399,7 +435,7 @@ module.exports = function (grunt) {
require('time-grunt')(grunt);
// Docs HTML validation task
- grunt.registerTask('validate-html', ['jekyll', 'validation']);
+ grunt.registerTask('validate-html', ['jekyll:docs', 'htmllint']);
var runSubset = function (subset) {
return !process.env.TWBS_TEST || process.env.TWBS_TEST === subset;
@@ -411,8 +447,10 @@ module.exports = function (grunt) {
// Test task.
var testSubtasks = [];
// Skip core tests if running a different subset of the test suite
- if (runSubset('core')) {
- testSubtasks = testSubtasks.concat(['dist-css', 'csslint', 'jshint', 'jscs', 'qunit', 'build-customizer-html']);
+ if (runSubset('core') &&
+ // Skip core tests if this is a Savage build
+ process.env.TRAVIS_REPO_SLUG !== 'twbs-savage/bootstrap') {
+ testSubtasks = testSubtasks.concat(['dist-css', 'dist-js', 'csslint:dist', 'test-js', 'docs']);
}
// Skip HTML validation if running a different subset of the test suite
if (runSubset('validate-html') &&
@@ -430,22 +468,20 @@ module.exports = function (grunt) {
testSubtasks.push('saucelabs-qunit');
}
grunt.registerTask('test', testSubtasks);
+ grunt.registerTask('test-js', ['jshint:core', 'jshint:test', 'jshint:grunt', 'jscs:core', 'jscs:test', 'jscs:grunt', 'qunit']);
// JS distribution task.
- grunt.registerTask('dist-js', ['concat', 'uglify']);
+ grunt.registerTask('dist-js', ['concat', 'uglify:core', 'commonjs']);
// CSS distribution task.
grunt.registerTask('less-compile', ['less:compileCore', 'less:compileTheme']);
- grunt.registerTask('dist-css', ['less-compile', 'autoprefixer', 'usebanner', 'csscomb', 'cssmin']);
-
- // Docs distribution task.
- grunt.registerTask('dist-docs', 'copy:docs');
+ grunt.registerTask('dist-css', ['less-compile', 'autoprefixer:core', 'autoprefixer:theme', 'csscomb:dist', 'cssmin:minifyCore', 'cssmin:minifyTheme']);
// Full distribution task.
- grunt.registerTask('dist', ['clean', 'dist-css', 'copy:fonts', 'dist-js', 'dist-docs']);
+ grunt.registerTask('dist', ['clean:dist', 'dist-css', 'copy:fonts', 'dist-js']);
// Default task.
- grunt.registerTask('default', ['test', 'dist', 'build-glyphicons-data', 'build-customizer']);
+ grunt.registerTask('default', ['clean:dist', 'copy:fonts', 'test']);
// Version numbering task.
// grunt change-version-number --oldver=A.B.C --newver=X.Y.Z
@@ -462,6 +498,21 @@ module.exports = function (grunt) {
generateRawFiles(grunt, banner);
});
+ grunt.registerTask('commonjs', 'Generate CommonJS entrypoint module in dist dir.', function () {
+ var srcFiles = grunt.config.get('concat.bootstrap.src');
+ var destFilepath = 'dist/js/npm.js';
+ generateCommonJSModule(grunt, srcFiles, destFilepath);
+ });
+
+ // Docs task.
+ grunt.registerTask('docs-css', ['autoprefixer:docs', 'autoprefixer:examples', 'csscomb:docs', 'csscomb:examples', 'cssmin:docs']);
+ grunt.registerTask('lint-docs-css', ['csslint:docs', 'csslint:examples']);
+ grunt.registerTask('docs-js', ['uglify:docsJs', 'uglify:customize']);
+ grunt.registerTask('lint-docs-js', ['jshint:assets', 'jscs:assets']);
+ grunt.registerTask('docs', ['docs-css', 'lint-docs-css', 'docs-js', 'lint-docs-js', 'clean:docs', 'copy:docs', 'build-glyphicons-data', 'build-customizer']);
+
+ grunt.registerTask('prep-release', ['dist', 'docs', 'jekyll:github', 'htmlmin', 'compress']);
+
// Task for updating the cached npm packages used by the Travis build (which are controlled by test-infra/npm-shrinkwrap.json).
// This task should be run and the updated file should be committed whenever Bootstrap's dependencies change.
grunt.registerTask('update-shrinkwrap', ['exec:npmUpdate', '_update-shrinkwrap']);
@@ -469,7 +520,7 @@ module.exports = function (grunt) {
var done = this.async();
npmShrinkwrap({ dev: true, dirname: __dirname }, function (err) {
if (err) {
- grunt.fail.warn(err)
+ grunt.fail.warn(err);
}
var dest = 'test-infra/npm-shrinkwrap.json';
fs.renameSync('npm-shrinkwrap.json', dest);