1 /* jshint node: true */
3 module.exports = function(grunt) {
6 // Project configuration.
10 pkg: grunt.file.readJSON('package.json'),
12 '* <%= pkg.name %>.js v<%= pkg.version %> by @fat and @mdo\n' +
13 '* Copyright <%= grunt.template.today("yyyy") %> <%= pkg.author %>\n' +
14 '* <%= _.pluck(pkg.licenses, "url").join(", ") %>\n' +
16 jqueryCheck: 'if (!jQuery) { throw new Error(\"Bootstrap requires jQuery\") }\n\n',
18 // Task configuration.
25 jshintrc: 'js/.jshintrc'
34 src: ['js/tests/unit/*.js']
40 banner: '<%= banner %><%= jqueryCheck %>',
58 dest: 'dist/js/<%= pkg.name %>.js'
64 banner: '<%= banner %>'
67 src: ['<%= concat.bootstrap.dest %>'],
68 dest: 'dist/js/<%= pkg.name %>.min.js'
77 src: ['less/bootstrap.less'],
78 dest: 'dist/css/<%= pkg.name %>.css'
84 src: ['less/bootstrap.less'],
85 dest: 'dist/css/<%= pkg.name %>.min.css'
88 src: ['less/theme.less'],
89 dest: 'dist/css/<%= pkg.name %>-theme.css'
95 src: ['less/theme.less'],
96 dest: 'dist/css/<%= pkg.name %>-theme.min.css'
110 inject: 'js/tests/unit/phantom.js'
112 files: ['js/tests/*.html']
133 src: ["_gh_pages/**/*.html"]
139 files: '<%= jshint.src.src %>',
140 tasks: ['jshint:src', 'qunit']
143 files: '<%= jshint.test.src %>',
144 tasks: ['jshint:test', 'qunit']
147 files: 'less/*.less',
154 // These plugins provide necessary tasks.
155 grunt.loadNpmTasks('grunt-contrib-clean');
156 grunt.loadNpmTasks('grunt-contrib-concat');
157 grunt.loadNpmTasks('grunt-contrib-connect');
158 grunt.loadNpmTasks('grunt-contrib-copy');
159 grunt.loadNpmTasks('grunt-contrib-jshint');
160 grunt.loadNpmTasks('grunt-contrib-qunit');
161 grunt.loadNpmTasks('grunt-contrib-uglify');
162 grunt.loadNpmTasks('grunt-contrib-watch');
163 grunt.loadNpmTasks('grunt-html-validation');
164 grunt.loadNpmTasks('grunt-jekyll');
165 grunt.loadNpmTasks('grunt-recess');
166 grunt.loadNpmTasks('browserstack-runner');
168 // Docs HTML validation task
169 grunt.registerTask('validate-html', ['jekyll', 'validation']);
172 var testSubtasks = ['dist-css', 'jshint', 'qunit', 'validate-html'];
173 // Only run BrowserStack tests under Travis
174 if (process.env.TRAVIS) {
175 // Only run BrowserStack tests if this is a mainline commit in twbs/bootstrap, or you have your own BrowserStack key
176 if ((process.env.TRAVIS_REPO_SLUG === 'twbs/bootstrap' && process.env.TRAVIS_PULL_REQUEST === 'false') || process.env.TWBS_HAVE_OWN_BROWSERSTACK_KEY) {
177 testSubtasks.push('browserstack_runner');
180 grunt.registerTask('test', testSubtasks);
182 // JS distribution task.
183 grunt.registerTask('dist-js', ['concat', 'uglify']);
185 // CSS distribution task.
186 grunt.registerTask('dist-css', ['recess']);
188 // Fonts distribution task.
189 grunt.registerTask('dist-fonts', ['copy']);
191 // Full distribution task.
192 grunt.registerTask('dist', ['clean', 'dist-css', 'dist-fonts', 'dist-js']);
195 grunt.registerTask('default', ['test', 'dist', 'build-customizer']);
197 // task for building customizer
198 grunt.registerTask('build-customizer', 'Add scripts/less files to customizer.', function () {
199 var fs = require('fs')
201 function getFiles(type) {
204 .filter(function (path) {
205 return type == 'fonts' ? true : new RegExp('\\.' + type + '$').test(path)
207 .forEach(function (path) {
208 return files[path] = fs.readFileSync(type + '/' + path, 'utf8')
210 return 'var __' + type + ' = ' + JSON.stringify(files) + '\n'
213 var customize = fs.readFileSync('customize.html', 'utf-8')
214 var files = getFiles('js') + getFiles('less') + getFiles('fonts')
215 fs.writeFileSync('assets/js/raw-files.js', files)