From b09a03afa239e0359247a31e9c23cc35bb92a955 Mon Sep 17 00:00:00 2001 From: Thomas Park Date: Mon, 7 Jul 2014 12:38:40 -0400 Subject: add grunt watch task, closes #281 --- Gruntfile.js | 15 +++++++++++++++ help/index.html | 5 ++--- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/Gruntfile.js b/Gruntfile.js index 0ebe8c40..9931a92b 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -8,6 +8,7 @@ module.exports = function (grunt) { grunt.initConfig({ pkg: grunt.file.readJSON('package.json'), builddir: '.', + buildtheme: '', banner: '/*!\n' + ' * <%= pkg.name %> v<%= pkg.version %>\n' + ' * Homepage: <%= pkg.homepage %>\n' + @@ -43,12 +44,20 @@ module.exports = function (grunt) { }, files: {} } + }, + watch: { + files: ['*/variables.less', '*/bootswatch.less'], + tasks: 'build', + options: { + nospawn: true + } } }); grunt.registerTask('none', function() {}); grunt.registerTask('build', 'build a regular theme', function(theme, compress) { + var theme = theme == undefined ? grunt.config('buildtheme') : theme; var compress = compress == undefined ? true : compress; var concatSrc; @@ -89,4 +98,10 @@ module.exports = function (grunt) { grunt.registerTask('default', 'build a theme', function() { grunt.task.run('swatch'); }); + + grunt.event.on('watch', function(action, filepath) { + var path = require('path'); + var theme = path.dirname(filepath); + grunt.config('buildtheme', theme); + }); }; diff --git a/help/index.html b/help/index.html index f6cc07c4..a43c1e1d 100644 --- a/help/index.html +++ b/help/index.html @@ -108,10 +108,9 @@
  1. git clone https://github.com/thomaspark/bootswatch.git

  2. npm install

  3. -
  4. -

    Edit variables.less and bootswatch.less in one of the theme directories, or create your own in /custom.

    -
  5. +
  6. Edit variables.less and bootswatch.less in one of the theme directories, or create your own in /custom.

  7. Type grunt swatch:[theme] to build the CSS for a theme, e.g., grunt swatch:amelia for Amelia. Or type grunt swatch to build them all at once. To have grunt available in the command line, install grunt-cli as described on the Grunt Getting Started page.

  8. +
  9. You can also run grunt watch to watch for any changes to the LESS files and automatically build a theme on change.

Here are additional tips for customizing Bootstrap.

-- cgit v1.2.3