From e69bfaa3530c0d004b83132c9276c1ce5c0271ef Mon Sep 17 00:00:00 2001 From: sami-t Date: Mon, 14 Jul 2014 16:49:00 -0700 Subject: [PATCH 1/4] Convert backslashes to slashes for Windows compatibility --- src/Gruntfile.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/Gruntfile.js b/src/Gruntfile.js index d97633728..7d192d1d7 100644 --- a/src/Gruntfile.js +++ b/src/Gruntfile.js @@ -60,6 +60,10 @@ module.exports = function(grunt) { ], setWatchFiles = function(action, filePath) { + // convert backslashes to slashes for Windows compatibility + if(process.platform === 'win32') { + filePath = filePath.replace(/\\/g, '/'); + } var outputPath = filePath.replace(paths.source.definitions, paths.output.uncompressed + 'definitions/') ; From 369817aa72a07831978ffd91f229c20840d9c436 Mon Sep 17 00:00:00 2001 From: sami-t Date: Mon, 14 Jul 2014 16:51:40 -0700 Subject: [PATCH 2/4] Correct watched path for .variables and .overrides files --- src/Gruntfile.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Gruntfile.js b/src/Gruntfile.js index 7d192d1d7..eb5219c94 100644 --- a/src/Gruntfile.js +++ b/src/Gruntfile.js @@ -115,8 +115,8 @@ module.exports = function(grunt) { src: { files: [ paths.source.definitions + '**/*.less', - paths.source.definitions + '**/*.variables', - paths.source.definitions + '**/*.overrides', + paths.source.themes + '**/*.variables', + paths.source.themes + '**/*.overrides', paths.source.definitions + '**/*.js' ], tasks : watchTasks From 0336c4aef450e0e4858836bd2adf1705b808b419 Mon Sep 17 00:00:00 2001 From: sami-t Date: Mon, 14 Jul 2014 17:39:01 -0700 Subject: [PATCH 3/4] Build .less file when relevant .overrides or .variables file is modified --- src/Gruntfile.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/Gruntfile.js b/src/Gruntfile.js index eb5219c94..e2e7eea29 100644 --- a/src/Gruntfile.js +++ b/src/Gruntfile.js @@ -64,6 +64,13 @@ module.exports = function(grunt) { if(process.platform === 'win32') { filePath = filePath.replace(/\\/g, '/'); } + var + re = new RegExp(paths.source.themes + '.*\/([^\/]*\/[^\/]*)\.(?:overrides|variables)$') + ; + // find relevant .less file for each modified .overrides or .variables file + if(filePath.search(re) !== -1) { + filePath = filePath.replace(re, paths.source.definitions + '$1.less'); + } var outputPath = filePath.replace(paths.source.definitions, paths.output.uncompressed + 'definitions/') ; From 0d19a1890ba16b9fd0fee4c569bbd6e1d94b752c Mon Sep 17 00:00:00 2001 From: sami-t Date: Mon, 14 Jul 2014 16:56:28 -0700 Subject: [PATCH 4/4] Use grunt-newer to quickly package and minify modified watched files --- src/Gruntfile.js | 15 ++++++++++++++- src/package.json | 3 ++- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/src/Gruntfile.js b/src/Gruntfile.js index e2e7eea29..844b74a14 100644 --- a/src/Gruntfile.js +++ b/src/Gruntfile.js @@ -20,7 +20,19 @@ module.exports = function(grunt) { 'copy:file', // auto prefix outputted file - 'autoprefixer:prefixFile' + 'autoprefixer:prefixFile', + + // creates minified js of outputted file if it is js + 'newer:uglify:minifyOutput', + + // creates minified css of outputted file if it is css + 'newer:cssmin:minifyOutput', + + // create concatenated css release if outputted file is css + 'newer:concat:createCSSPackage', + + // create concatenated js release if outputted file is js + 'newer:concat:createJSPackage' ], resetTasks = [ @@ -296,6 +308,7 @@ module.exports = function(grunt) { grunt.loadNpmTasks('grunt-contrib-copy'); grunt.loadNpmTasks('grunt-clear'); grunt.loadNpmTasks('grunt-contrib-concat'); + grunt.loadNpmTasks('grunt-newer'); // css grunt.loadNpmTasks('grunt-contrib-cssmin'); diff --git a/src/package.json b/src/package.json index bd0b6d063..2439587bd 100644 --- a/src/package.json +++ b/src/package.json @@ -15,6 +15,7 @@ "grunt-contrib-less": "~0.7.0", "grunt-contrib-concat": "~0.3.0", "grunt-clear": "~0.2.1", - "grunt-autoprefixer": "~0.4.0" + "grunt-autoprefixer": "~0.4.0", + "grunt-newer": "~0.7.0" } }