Commit 5fb0d69e authored by Mark Otto's avatar Mark Otto

Merge pull request #9050 from jonschlinkert/3.0.0-wip

organizes the Gruntfile a bit and makes better use of Grunt conventions 
parents 98b50abe 55df26ae
/* jshint node: true */ /* jshint node: true */
module.exports = function(grunt) { module.exports = function(grunt) {
"use strict"; "use strict";
// Project configuration. // Project configuration.
grunt.initConfig({ grunt.initConfig({
// Metadata.
pkg: grunt.file.readJSON('package.json'), // Metadata.
banner: '/**\n' + pkg: grunt.file.readJSON('package.json'),
'* <%= pkg.name %>.js v<%= pkg.version %> by @fat and @mdo\n' + banner: '/**\n' +
'* Copyright <%= grunt.template.today("yyyy") %> <%= pkg.author %>\n' + '* <%= pkg.name %>.js v<%= pkg.version %> by @fat and @mdo\n' +
'* <%= _.pluck(pkg.licenses, "url").join(", ") %>\n' + '* Copyright <%= grunt.template.today("yyyy") %> <%= pkg.author %>\n' +
'*/\n', '* <%= _.pluck(pkg.licenses, "url").join(", ") %>\n' +
jqueryCheck: 'if (!jQuery) { throw new Error(\"Bootstrap requires jQuery\") }\n\n', '*/\n',
// Task configuration. jqueryCheck: 'if (!jQuery) { throw new Error(\"Bootstrap requires jQuery\") }\n\n',
clean: {
dist: ['dist'] // Task configuration.
}, clean: {
concat: { dist: ['dist']
options: { },
banner: '<%= banner %><%= jqueryCheck %>',
stripBanners: false jshint: {
}, options: {
bootstrap: { jshintrc: 'js/.jshintrc'
src: ['js/transition.js', 'js/alert.js', 'js/button.js', 'js/carousel.js', 'js/collapse.js', 'js/dropdown.js', 'js/modal.js', 'js/tooltip.js', 'js/popover.js', 'js/scrollspy.js', 'js/tab.js', 'js/affix.js'], },
dest: 'dist/js/<%= pkg.name %>.js' gruntfile: {
} src: 'Gruntfile.js'
}, },
jshint: { src: {
options: { src: ['js/*.js']
jshintrc: 'js/.jshintrc' },
}, test: {
gruntfile: { src: ['js/tests/unit/*.js']
src: 'Gruntfile.js' }
}, },
src: { concat: {
src: ['js/*.js'] options: {
}, banner: '<%= banner %><%= jqueryCheck %>',
test: { stripBanners: false
src: ['js/tests/unit/*.js'] },
} bootstrap: {
}, src: [
recess: { 'js/transition.js',
options: { 'js/alert.js',
compile: true 'js/button.js',
}, 'js/carousel.js',
bootstrap: { 'js/collapse.js',
files: { 'js/dropdown.js',
'dist/css/bootstrap.css': ['less/bootstrap.less'] 'js/modal.js',
} 'js/tooltip.js',
}, 'js/popover.js',
min: { 'js/scrollspy.js',
options: { 'js/tab.js',
compress: true 'js/affix.js'
}, ],
files: { dest: 'dist/js/<%= pkg.name %>.js'
'dist/css/bootstrap.min.css': ['less/bootstrap.less'] }
} },
} uglify: {
}, options: {
uglify: { banner: '<%= banner %>'
options: { },
banner: '<%= banner %>' bootstrap: {
}, src: ['<%= concat.bootstrap.dest %>'],
bootstrap: { dest: 'dist/js/<%= pkg.name %>.min.js'
files: { }
'dist/js/<%= pkg.name %>.min.js': ['<%= concat.bootstrap.dest %>'] },
}
} recess: {
}, options: {
qunit: { compile: true
options: { },
inject: 'js/tests/unit/phantom.js' bootstrap: {
}, src: ['less/bootstrap.less'],
files: ['js/tests/*.html'] dest: 'dist/css/<%= pkg.name %>.css'
}, },
connect: { min: {
server: { options: {
options: { compress: true
port: 3000,
base: '.'
}
}
}, },
watch: { src: ['less/bootstrap.less'],
src: { dest: 'dist/css/<%= pkg.name %>.min.css'
files: '<%= jshint.src.src %>', }
tasks: ['jshint:src', 'qunit'] },
},
test: { qunit: {
files: '<%= jshint.test.src %>', options: {
tasks: ['jshint:test', 'qunit'] inject: 'js/tests/unit/phantom.js'
}, },
recess: { files: ['js/tests/*.html']
files: 'less/*.less', },
tasks: ['recess'] connect: {
} server: {
options: {
port: 3000,
base: '.'
} }
}); }
},
watch: {
src: {
files: '<%= jshint.src.src %>',
tasks: ['jshint:src', 'qunit']
},
test: {
files: '<%= jshint.test.src %>',
tasks: ['jshint:test', 'qunit']
},
recess: {
files: 'less/*.less',
tasks: ['recess']
}
}
});
// These plugins provide necessary tasks. // These plugins provide necessary tasks.
grunt.loadNpmTasks('grunt-contrib-connect'); grunt.loadNpmTasks('grunt-contrib-clean');
grunt.loadNpmTasks('grunt-contrib-clean'); grunt.loadNpmTasks('grunt-contrib-concat');
grunt.loadNpmTasks('grunt-contrib-concat'); grunt.loadNpmTasks('grunt-contrib-connect');
grunt.loadNpmTasks('grunt-contrib-jshint'); grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.loadNpmTasks('grunt-contrib-uglify'); grunt.loadNpmTasks('grunt-contrib-qunit');
grunt.loadNpmTasks('grunt-contrib-qunit'); grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-contrib-watch'); grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-recess'); grunt.loadNpmTasks('grunt-recess');
// Test task. // Test task.
grunt.registerTask('test', ['jshint', 'qunit']); grunt.registerTask('test', ['jshint', 'qunit']);
// JS distribution task. // JS distribution task.
grunt.registerTask('dist-js', ['concat', 'uglify']); grunt.registerTask('dist-js', ['concat', 'uglify']);
// CSS distribution task. // CSS distribution task.
grunt.registerTask('dist-css', ['recess']); grunt.registerTask('dist-css', ['recess']);
// Full distribution task. // Full distribution task.
grunt.registerTask('dist', ['clean', 'dist-css', 'dist-js']); grunt.registerTask('dist', ['clean', 'dist-css', 'dist-js']);
// Default task. // Default task.
grunt.registerTask('default', ['test', 'dist']); grunt.registerTask('default', ['test', 'dist']);
}; };
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment