Skip to content

Commit

Permalink
feat(jsconcat): allow opting-out of minification
Browse files Browse the repository at this point in the history
  • Loading branch information
Florens Verschelde committed Jul 15, 2016
1 parent 6b882cb commit a65e183
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
```

Expand Down
5 changes: 4 additions & 1 deletion gulp/builders/jsconcat.js
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand All @@ -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) )
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down

0 comments on commit a65e183

Please sign in to comment.