diff --git a/package.json b/package.json index 00c95140e..9c932cd77 100644 --- a/package.json +++ b/package.json @@ -36,6 +36,7 @@ "gulp-notify": "*", "gulp-plumber": "*", "gulp-print": "*", + "gulp-purifycss": "*", "gulp-rename": "*", "gulp-replace": "*", "gulp-rtlcss": "*", @@ -68,6 +69,7 @@ "gulp-plumber": "^1.0.1", "gulp-print": "^1.1.0", "gulp-prompt": "^0.1.2", + "gulp-purifycss": "^0.2.0", "gulp-rename": "^1.2.2", "gulp-replace": "^0.5.3", "gulp-rtlcss": "^0.1.4", diff --git a/semantic.json.example b/semantic.json.example index 39f4bfeb2..d78f9350a 100644 --- a/semantic.json.example +++ b/semantic.json.example @@ -2,6 +2,7 @@ "base": "", "paths": { + "purify": false, "source": { "config" : "src/theme.config", "definitions" : "src/definitions/", diff --git a/tasks/build/css.js b/tasks/build/css.js index 137d11724..a0c629906 100644 --- a/tasks/build/css.js +++ b/tasks/build/css.js @@ -19,6 +19,7 @@ var minifyCSS = require('gulp-minify-css'), plumber = require('gulp-plumber'), print = require('gulp-print'), + purifyCSS = require('gulp-purifycss'), rename = require('gulp-rename'), replace = require('gulp-replace'), @@ -57,10 +58,13 @@ module.exports = function(callback) { return; } + console.log(config.purify); + // unified css stream stream = gulp.src(source.definitions + '/**/' + globs.components + '.less') .pipe(plumber(settings.plumber.less)) .pipe(less(settings.less)) + .pipe(gulpif(config.purify, purifyCSS(config.purify))) .pipe(autoprefixer(settings.prefix)) .pipe(replace(comments.variables.in, comments.variables.out)) .pipe(replace(comments.license.in, comments.license.out)) diff --git a/tasks/config/defaults.js b/tasks/config/defaults.js index 2c0e9ebfb..2ff66d0c6 100644 --- a/tasks/config/defaults.js +++ b/tasks/config/defaults.js @@ -23,6 +23,9 @@ module.exports = { theme : 'src/theme.config' }, + // Array of paths to run purify-css against + purify: false, + // folder paths paths: { source: { diff --git a/tasks/watch.js b/tasks/watch.js index 964835a00..0c2d1c76f 100644 --- a/tasks/watch.js +++ b/tasks/watch.js @@ -19,6 +19,7 @@ var plumber = require('gulp-plumber'), print = require('gulp-print'), rename = require('gulp-rename'), + purifyCSS = require('gulp-purifycss'), replace = require('gulp-replace'), uglify = require('gulp-uglify'), util = require('gulp-util'), @@ -138,6 +139,8 @@ module.exports = function(callback) { if( fs.existsSync(lessPath) ) { + console.log(config.purify); + // unified css stream stream = gulp.src(lessPath) .pipe(plumber(settings.plumber.less)) @@ -148,6 +151,7 @@ module.exports = function(callback) { .pipe(replace(comments.large.in, comments.large.out)) .pipe(replace(comments.small.in, comments.small.out)) .pipe(replace(comments.tiny.in, comments.tiny.out)) + .pipe(gulpif(config.purify, purifyCSS(config.purify))) .pipe(autoprefixer(settings.prefix)) .pipe(gulpif(config.hasPermission, chmod(config.permission))) ;