Skip to content

Instantly share code, notes, and snippets.

@davidtheclark
Last active December 16, 2015 15:08
Show Gist options
  • Save davidtheclark/5453277 to your computer and use it in GitHub Desktop.
Save davidtheclark/5453277 to your computer and use it in GitHub Desktop.
De-Fancify Bootstrap with Grunt, using the grunt-text-replace plugin. After installing grunt-text-replace, incorporate this code into your own grunt.initConfig object. The goal is to remove box-shadows, text-shadows, border-radii, gradients, and gradientBars from Bootstrap's standard UI elements -- outputting a version of Bootstrap's LESS (or SC…
/*
Grunt is here: http://gruntjs.com/
The plugin grunt-text-replace is here: https://github.com/yoniholmes/grunt-text-replace
After reading those instructions, it should be clear how to use the following.
*/
module.exports = function(grunt) {
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
replace: {
// This is the important part: a subtask that consists of a series of regex find/replace commands.
removeFanciness: {
// Set your source. The path below is useful if you installed Bootstrap with Bower.
src: ['components/bootstrap/less/*.less'],
// Set the destination directory for your modified LESS.
dest: 'styles/less/bootstrap-build/',
replacements: [{
from: /(.(box-shadow|#gradient|gradientBar|border-.*radius).*\;)/g,
to: '//--de-fancified!-- $1'
}, {
from: /(text-shadow.*\;)/g,
to: '//--de-fancified!-- $1'
}]
}
}
});
grunt.loadNpmTasks('grunt-text-replace');
// Register the task however you see fit.
grunt.registerTask('bootstrap-build', ['replace']);
};
// AND here's the same idea, but for SCSS
module.exports = function(grunt) {
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
replace: {
removeFanciness: {
src: ['components/sass-bootstrap/lib/*.scss'],
dest: 'styles/scss/bootstrap-build/',
replacements: [{
from: /(@include (box-shadow|gradient|border-.*radius).*\;)/g,
to: '//--de-fancified!-- $1'
}, {
from: /(text-shadow.*\;)/g,
to: '//--de-fancified!-- $1'
}]
}
}
});
grunt.loadNpmTasks('grunt-text-replace');
grunt.registerTask('bootstrap-build', ['replace:removeFanciness']);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment