forked from gulpjs/gulp
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add recipe for outputting both minified and non-minified scripts
- Loading branch information
Showing
2 changed files
with
25 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)); | ||
}); | ||
|
||
``` |