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.
A recipe for passing parameters from the command line
- Loading branch information
Showing
3 changed files
with
29 additions
and
1 deletion.
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,27 @@ | ||
# Pass parameters from the command line | ||
## bonus: keeping those tasks DRY | ||
|
||
--- | ||
|
||
`gulpfile.js` | ||
|
||
```js | ||
// npm install gulp gulp-if gulp-uglify | ||
var gulp = require('gulp'); | ||
var gulpif = require('gulp-if'); | ||
var uglify = require('gulp-uglify'); | ||
|
||
var isProduction = gulp.env.type === 'production'; | ||
|
||
gulp.task('scripts', function () { | ||
return gulp.src('**/*.js') | ||
.pipe(gulpif(isProduction, uglify())) // only minify if production | ||
.pipe(gulp.dest('dist')); | ||
}); | ||
``` | ||
|
||
--- | ||
|
||
`cli` | ||
|
||
`gulp scripts --type production` |
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