diff --git a/README.md b/README.md index d50f226..3863d87 100644 --- a/README.md +++ b/README.md @@ -92,7 +92,9 @@ Task script: `gulp/builders/jsconcat.js` dest: 'public/js/main.js', // (Optional) File patterns to watch for changes, or `true` // to use the same value as the src property - watch: true + watch: true, + // (Optional) Should we minify the result? Default is true. + minify: true } ``` diff --git a/gulp/builders/jsconcat.js b/gulp/builders/jsconcat.js index 290c04c..15b4f5b 100644 --- a/gulp/builders/jsconcat.js +++ b/gulp/builders/jsconcat.js @@ -6,6 +6,7 @@ // Core tools var concat = require('gulp-concat') var gulp = require('gulp') +var gulpif = require('gulp-if') var path = require('path') var plumber = require('gulp-plumber') var sourcemaps = require('gulp-sourcemaps') @@ -23,13 +24,15 @@ var showSize = require('../helpers/size.js') * @returns {*} */ module.exports = function buildJsConcat(config) { + // Opt-out of minification with any falsy value + var shouldMinify = 'minify' in config ? Boolean(config.minify) : true var destInfo = path.parse(config.dest) return gulp.src(config.src) .pipe( plumber(notify) ) .pipe( sourcemaps.init() ) .pipe( concat(destInfo.base) ) - .pipe( uglify() ) + .pipe( gulpif(shouldMinify, uglify()) ) .pipe( showSize(destInfo.dir) ) .pipe( sourcemaps.write('.') ) .pipe( gulp.dest(destInfo.dir) ) diff --git a/package.json b/package.json index fb7db75..db5da78 100644 --- a/package.json +++ b/package.json @@ -15,6 +15,7 @@ "gulp": "^3.9", "gulp-autoprefixer": "^3.1", "gulp-concat": "^2.6", + "gulp-if": "^2.0.1", "gulp-plumber": "^1.1", "gulp-sass": "^2.3", "gulp-size": "^2.1",