Skip to content

Commit

Permalink
Add recipe for outputting both minified and non-minified scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
Daniel15 committed Sep 7, 2014
1 parent 8f505c9 commit 61b5751
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
1 change: 1 addition & 0 deletions docs/recipes/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,4 @@
* [Using external config file](using-external-config-file.md)
* [Using multiple sources in one task](using-multiple-sources-in-one-task.md)
* [Browserify + Uglify with sourcemaps](browserify-uglify-sourcemap.md)
* [Output both a minified and non-minified version](minified-and-non-minified.md)
24 changes: 24 additions & 0 deletions docs/recipes/minified-and-non-minified.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Output both a minified and non-minified version

Outputting both a minified and non-minified version of your combined JavaScript files can be achieved by using `gulp-rename` and piping to `dest` twice (once before minifying and once after minifying):

```js
'use strict';

var gulp = require('gulp');
var rename = require('gulp-rename');
var uglify = require('gulp-uglify');

var DEST = 'build/';

gulp.task('default', function() {
return gulp.src('foo.js')
// This will output the non-minified version
.pipe(gulp.dest(DEST))
// This will minify and rename to foo.min.js
.pipe(uglify())
.pipe(rename({ extname: '.min.js' }))
.pipe(gulp.dest(DEST));
});

```

0 comments on commit 61b5751

Please sign in to comment.