Skip to content

Instantly share code, notes, and snippets.

@thathurtabit
Created August 13, 2014 16:29
Show Gist options
  • Save thathurtabit/18999c85dc52fd94b798 to your computer and use it in GitHub Desktop.
Save thathurtabit/18999c85dc52fd94b798 to your computer and use it in GitHub Desktop.
Grunt Bower Bootstrap
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/*", "lib/*", "js/*/**", "!less", "!css/main.css", '!js/*.js', "!node_modules", "!Gruntfile.js", "!package.json", "!deploy", "!doc", "!src" ],
dest: 'deploy/'
}
},
// LESS - https://github.com/gruntjs/grunt-contrib-less
less: {
deploy: {
options: {
compress: true
},
files: [
{ src: ["less/index.less"], dest: "deploy/css/extel.min.css"}
],
}
},
// split CSS for IE selector limit - https://github.com/Ponginae/grunt-bless
bless: {
deploy: {
options: {
compress: true,
cleanup: true,
imports: false
},
files: [
{ src: ["deploy/css/extel.min.css"], dest: "deploy/css/extel.min.ie.css"},
]
}
},
// UGLIFY - https://github.com/gruntjs/grunt-contrib-uglify
uglify: {
deploy: {
files: [
{ src: ["js/script.js"], dest: "deploy/js/script.js"},
{ src: ["js/plugins.js"], dest: "deploy/js/plugins.js"},
{ src: ["js/bootstrap.min.js"], dest: "deploy/js/bootstrap.min.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: '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", "js/bootstrap.min.js"],
tasks: ['uglify:deploy'],
options: {
//interrupt: true
}
},
less: {
files: 'less/*/**',
tasks: ['less:deploy'],
options: {
//interrupt: true
}
},
copy: {
files: ["*", "css/*.css", "img/*", "css/fonts/*", "lib/*", "js/*/**", "!css/less", "!css/main.css", '!js/*.js', "!node_modules", "!docs", "!grunt", "!Gruntfile.js", "!package.json", "!deploy", "!doc", "!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');
grunt.loadNpmTasks('grunt-bless');
// Resigster tasks in order
// Make sure WATCH is last
grunt.registerTask('default', [ 'less', 'copy', 'uglify', 'concat', 'bless', 'connect', 'watch']);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment