gulp package management helper
Features
- Smart package-require notation
- Add 'install' task to your gulpfile
- Add 'uninstall' task to your gulpfile
For more details
Install
$ npm install gulp-packages
Features1: Smart package-require notation
BEFORE
gulpfile.js
var gulp = require('gulp');
var less = require('gulp-less');
var coffee = require('gulp-coffee');
var pleeease = require('gulp-pleeease');
var minifyCss = require('gulp-minify-css');
var taskListing = require('gulp-task-listing');
var minHtm = require('gulp-html-minifier');
var uglify = require('gulp-uglify');
var rename = require('gulp-rename');
var watch = require('gulp-watch');
var plumber = require('gulp-plumber');
var coffeelint = require('gulp-coffeelint');
var concat = require('gulp-concat');
AFTER
gulpfile.js
var gulp = require('gulp');
var pkg = require('gulp-packages')(gulp, [
'less',
'coffee',
'pleeease',
'minify-css',
'taskListing',
'html-minifier as minHtm',
'uglify',
'rename',
'watch',
'plumber',
'coffeelint',
'concat'
]);
For the above example, Packages are loaded into pkg
variable.
Use of loaded packages
gulp.src('/path/to/*.coffee')
.pipe(pkg.plumber())
.pipe(pkg.coffee())
.pipe(pkg.uglify())
.pipe(gulp.dest('js/'));
Features2: Add 'install' task to your gulpfile
When the following conditions:
gulpfile.js
var gulp = require('gulp');
var pkg = require('gulp-packages')(gulp, [
'less',
'coffee',
'pleeease',
'minify-css',
'taskListing',
'uglify',
'html-minifier as minHtm',
'rename',
'watch',
'plumber',
'coffeelint',
'concat'
]);
BEFORE
$ npm install gulp-uglify gulp-html-minifier gulp-rename gulp-plumber gulp-concat --save-dev
AFTER
$ gulp install
Features3: Add 'uninstall' task to your gulpfile
When the following conditions:
gulpfile.js
var gulp = require('gulp');
var pkg = require('gulp-packages')(gulp, [
'less',
'coffee',
'pleeease',
'minify-css',
'taskListing',
'watch',
'coffeelint',
]);
and
package.json
{
"devDependencies": {
"coffee-script": "*",
"gulp": "*",
"gulp-coffee": "*",
"gulp-coffeelint": "*",
"gulp-concat": "*", // <- no longer using
"gulp-less": "*",
"gulp-minify-css": "*",
"gulp-pleeease": "*",
"gulp-plumber": "*", // <- no longer using
"gulp-rename": "*", // <- no longer using
"gulp-uglify": "*", // <- no longer using
"gulp-html-minifier": "*", // <- no longer using
"gulp-watch": "*",
"gulp-task-listing": "*"
}
}
BEFORE
$ npm uninstall gulp-concat gulp-plumber gulp-rename gulp-uglify gulp-html-minifier --save-dev
AFTER
$ gulp uninstall
Package name rule
- Remove 'gulp-'
- [optional] Convert to CamelCase (You can specify non-converted package name. But you must convert to CamelCase when call it)
- "as" overwrites call name for shorter or else
Example
gulp-name | pkg-name | call-name | note |
---|
gulp-uglify | 'uglify' | pkg.uglify() | |
gulp-minify-css | 'minifyCss' | pkg.minifyCss() | CamelCase of package name |
gulp-minify-css | 'minify-css' | pkg.minifyCss() | Specify non-converted package name |
gulp-minify-css | 'minify-css as minCss' | pkg.minCss() | Using alias |
Changelog
0.2.0 (2014-08-30)
- Package name alias (using "as") supported
- Removed internal properties from gulp object
- Show warning when package duplicated
0.1.3 (2014-07-27)
- Added 'gulpfriendly' keyword to package.json
0.1.2 (2014-07-27)
- 'install' and 'uninstall' changed to synchronized task
- Colored message supported
- Added jshint options comment
- Fixed some messages
0.1.1 (2014-07-27)
- Changed to exclude 'gulp-packages' from uninstall target
0.1.0 (2014-07-26)
License
MIT license
© 2014 ktty1220