Skip to content

Commit

Permalink
"Remove gulp-load-plugins dependency" from Sage: roots/sage@4a9b066
Browse files Browse the repository at this point in the history
  • Loading branch information
JulienMelissas committed May 6, 2015
1 parent de13cbc commit ce27519
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 49 deletions.
109 changes: 61 additions & 48 deletions gulpfile.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,24 @@
// ## Globals
/*global $:true*/
var $ = require('gulp-load-plugins')();
var argv = require('minimist')(process.argv.slice(2));
var browserSync = require('browser-sync');
var gulp = require('gulp');
var lazypipe = require('lazypipe');
var merge = require('merge-stream');
var runSequence = require('run-sequence');
var argv = require('minimist')(process.argv.slice(2));
var autoprefixer = require('gulp-autoprefixer');
var browserSync = require('browser-sync');
var changed = require('gulp-changed');
var concat = require('gulp-concat');
var flatten = require('gulp-flatten');
var gulp = require('gulp');
var gulpif = require('gulp-if');
var imagemin = require('gulp-imagemin');
var jshint = require('gulp-jshint');
var lazypipe = require('lazypipe');
var less = require('gulp-less');
var merge = require('merge-stream');
var minifyCss = require('gulp-minify-css');
var plumber = require('gulp-plumber');
var rev = require('gulp-rev');
var runSequence = require('run-sequence');
var sass = require('gulp-sass');
var sourcemaps = require('gulp-sourcemaps');
var uglify = require('gulp-uglify');

// See https://github.com/austinpray/asset-builder
var manifest = require('asset-builder')('./assets/manifest.json');
Expand Down Expand Up @@ -64,38 +76,39 @@ var revManifest = path.dist + 'assets.json';
var cssTasks = function(filename) {
return lazypipe()
.pipe(function() {
return $.if(!enabled.failStyleTask, $.plumber());
return gulpif(!enabled.failStyleTask, plumber());
})
.pipe(function() {
return $.if(enabled.maps, $.sourcemaps.init());
return gulpif(enabled.maps, sourcemaps.init());
})
.pipe(function() {
return $.if('*.less', $.less());
})
.pipe(function() {
return $.if('*.scss', $.sass({
outputStyle: 'nested', // libsass doesn't support expanded yet
precision: 10,
includePaths: ['.'],
errLogToConsole: !enabled.failStyleTask
}));
})
.pipe($.concat, filename)
.pipe($.autoprefixer, {
browsers: [
'last 2 versions', 'ie 8', 'ie 9', 'android 2.3', 'android 4',
'opera 12'
]
})
.pipe(minifyCss, {
advanced: false,
rebase: false
})
.pipe(function() {
return $.if(enabled.rev, $.rev());
return gulpif('*.less', less());
})
.pipe(function() {
return $.if(enabled.maps, $.sourcemaps.write('.'));
return gulpif('*.scss', sass({
outputStyle: 'nested', // libsass doesn't support expanded yet
precision: 10,
includePaths: ['.'],
errLogToConsole: !enabled.failStyleTask
}));
})
.pipe(concat, filename)
.pipe(autoprefixer, {
browsers: [
'last 2 versions',
'ie 8',
'ie 9',
'android 2.3',
'android 4',
'opera 12'
]
})
.pipe(minifyCss)
.pipe(function() {
return gulpif(enabled.rev, rev());
})
.pipe(function() {
return gulpif(enabled.maps, sourcemaps.write('.'));
})();
};

Expand All @@ -109,15 +122,15 @@ var cssTasks = function(filename) {
var jsTasks = function(filename) {
return lazypipe()
.pipe(function() {
return $.if(enabled.maps, $.sourcemaps.init());
return gulpif(enabled.maps, sourcemaps.init());
})
.pipe($.concat, filename)
.pipe($.uglify)
.pipe(concat, filename)
.pipe(uglify)
.pipe(function() {
return $.if(enabled.rev, $.rev());
return gulpif(enabled.rev, rev());
})
.pipe(function() {
return $.if(enabled.maps, $.sourcemaps.write('.'));
return gulpif(enabled.maps, sourcemaps.write('.'));
})();
};

Expand All @@ -128,9 +141,9 @@ var writeToManifest = function(directory) {
return lazypipe()
.pipe(gulp.dest, path.dist + directory)
.pipe(function() {
return $.if('**/*.{js,css}', browserSync.reload({stream:true}));
return gulpif('**/*.{js,css}', browserSync.reload({stream:true}));
})
.pipe($.rev.manifest, revManifest, {
.pipe(rev.manifest, revManifest, {
base: path.dist,
merge: true
})
Expand Down Expand Up @@ -181,15 +194,15 @@ gulp.task('scripts', ['jshint'], function() {
// structure. See: https://github.com/armed/gulp-flatten
gulp.task('fonts', function() {
return gulp.src(globs.fonts)
.pipe($.flatten())
.pipe(flatten())
.pipe(gulp.dest(path.dist + 'fonts'));
});

// ### Images
// `gulp images` - Run lossless compression on all the images.
gulp.task('images', function() {
return gulp.src(globs.images)
.pipe($.imagemin({
.pipe(imagemin({
progressive: true,
interlaced: true,
svgoPlugins: [{removeUnknownsAndDefaults: false}]
Expand All @@ -203,9 +216,9 @@ gulp.task('jshint', function() {
return gulp.src([
'bower.json', 'gulpfile.js'
].concat(project.js))
.pipe($.jshint())
.pipe($.jshint.reporter('jshint-stylish'))
.pipe($.jshint.reporter('fail'));
.pipe(jshint())
.pipe(jshint.reporter('jshint-stylish'))
.pipe(jshint.reporter('fail'));
});

// ### Clean
Expand Down Expand Up @@ -249,8 +262,8 @@ gulp.task('wiredep', function() {
var wiredep = require('wiredep').stream;
return gulp.src(project.css)
.pipe(wiredep())
.pipe($.changed(path.source + 'styles', {
hasChanged: $.changed.compareSha1Digest
.pipe(changed(path.source + 'styles', {
hasChanged: changed.compareSha1Digest
}))
.pipe(gulp.dest(path.source + 'styles'));
});
Expand Down
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@
"gulp-imagemin": "^2.2.1",
"gulp-jshint": "^1.9.4",
"gulp-less": "^3.0.2",
"gulp-load-plugins": "^0.10.0",
"gulp-minify-css": "^1.0.0",
"gulp-plumber": "^1.0.0",
"gulp-rename": "^1.2.0",
Expand Down

0 comments on commit ce27519

Please sign in to comment.