Last active
August 29, 2015 14:02
-
-
Save thathurtabit/347206fe95661a0043e6 to your computer and use it in GitHub Desktop.
Bootstrap LESS setup with Bower Structure
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module.exports = function(grunt) { | |
// Project configuration. | |
grunt.initConfig({ | |
//Read the package.json (optional) | |
pkg: grunt.file.readJSON('package.json'), | |
// Metadata. | |
meta: { | |
basePath: '', | |
srcPath: 'js/', | |
deployPath: 'deploy/' | |
}, | |
// ================================== | |
// TASKS CONFIG | |
// COPY FILES FROM SOURCE TO DEPLOY - https://github.com/gruntjs/grunt-contrib-copy | |
// don't include '!X' | |
copy: { | |
deploy: { | |
expand: true, | |
src: ["*", "css/*.css", "img/*", "css/fonts/*", "js/*/**", "!css/less", "!css/main.css", '!js/*.js', "!node_modules", "!dist", "!less", "!docs", "!grunt", "!Gruntfile.js", "!package.json", "!deploy", "!bower_components", "!test-infra", "!grunt", "!doc", "!docs", "!src" ], | |
dest: 'deploy/' | |
} | |
}, | |
// LESS - https://github.com/gruntjs/grunt-contrib-less | |
less: { | |
deploy: { | |
options: { | |
compress: true | |
}, | |
files: [ | |
{ src: ["less/bootstrap.less"], dest: "deploy/css/bootstrap.min.css"} | |
], | |
} | |
}, | |
// UGLIFY - https://github.com/gruntjs/grunt-contrib-uglify | |
uglify: { | |
deploy: { | |
files: [ | |
{ src: ["js/scripts.js"], dest: "deploy/js/scripts.js"}, | |
{ src: ["js/plugins.js"], dest: "deploy/js/plugins.js"}, | |
], | |
} | |
}, | |
// CONNECT - Create server - https://github.com/gruntjs/grunt-contrib-connect | |
connect: { | |
server: { | |
options: { | |
port: 9999, | |
base: 'deploy' | |
} | |
} | |
}, | |
// CONCAT JS SCRIPTS | |
concat: { | |
deploy: { | |
src: [ | |
'bower_components/bootstrap/js/transition.js', | |
'bower_components/bootstrap/js/alert.js', | |
'bower_components/bootstrap/js/button.js', | |
'bower_components/bootstrap/js/carousel.js', | |
'bower_components/bootstrap/js/collapse.js', | |
'bower_components/bootstrap/js/dropdown.js', | |
'bower_components/bootstrap/js/modal.js', | |
'bower_components/bootstrap/js/tooltip.js', | |
'bower_components/bootstrap/js/popover.js', | |
'bower_components/bootstrap/js/scrollspy.js', | |
'bower_components/bootstrap/js/tab.js', | |
'bower_components/bootstrap/js/affix.js' | |
], | |
dest: 'deploy/js/bootstrap.min.js' | |
} | |
}, | |
// WATCH FILES & FOLDERS - https://github.com/gruntjs/grunt-contrib-watch | |
// Executes the listed targets on file save | |
// Watches folders for file changes and then runs the specified tasks | |
watch: { | |
uglify: { | |
files: ["js/script.js", "js/plugins.js"], | |
tasks: ['uglify:deploy'], | |
options: { | |
//interrupt: true | |
} | |
}, | |
less: { | |
files: 'less/*.less', | |
tasks: ['less:deploy'], | |
options: { | |
//interrupt: true | |
} | |
}, | |
copy: { | |
files: ["*", "css/*.css", "img/*", "css/fonts/*", "js/*/**", "!css/less", "!css/main.css", '!js/*.js', "!node_modules", "!dist", "!less", "!docs", "!grunt", "!Gruntfile.js", "!package.json", "!deploy", "!bower_components", "!test-infra", "!grunt", "!doc", "!docs", "!src" ], | |
tasks: ['copy:deploy'], | |
options: { | |
//interrupt: true, | |
//nospawn: true // commented out to make sure files are being copied to deploy on change | |
} | |
} | |
} | |
}); | |
// These plugins provide necessary tasks. | |
grunt.loadNpmTasks('grunt-contrib-concat'); | |
grunt.loadNpmTasks('grunt-contrib-uglify'); | |
grunt.loadNpmTasks('grunt-contrib-copy'); | |
grunt.loadNpmTasks('grunt-contrib-concat'); | |
grunt.loadNpmTasks('grunt-contrib-less'); | |
grunt.loadNpmTasks('grunt-contrib-watch'); | |
grunt.loadNpmTasks('grunt-contrib-connect'); | |
// Resigster tasks in order | |
// Make sure WATCH is last | |
grunt.registerTask('default', [ 'less', 'copy', 'uglify', 'concat', 'connect', 'watch']); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment