Last active
November 3, 2015 19:23
-
-
Save mendaomn/a316408d9b9ab5b6f17a to your computer and use it in GitHub Desktop.
Gulpfile - JS, CSS, Angular templates, uncss
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
// Load plugins | |
var gulp = require('gulp'), | |
autoprefixer = require('gulp-autoprefixer'), | |
concatcss = require('gulp-concat-css'), | |
minifycss = require('gulp-minify-css'), | |
uncss = require('gulp-uncss'), | |
jshint = require('gulp-jshint'), | |
uglify = require('gulp-uglify'), | |
imagemin = require('gulp-imagemin'), | |
rename = require('gulp-rename'), | |
concat = require('gulp-concat'), | |
notify = require('gulp-notify'), | |
changed = require('gulp-changed'), | |
order = require('gulp-order'), | |
cache = require('gulp-cache'), | |
templates = require('gulp-angular-templatecache'), | |
minifyHTML = require('gulp-minify-html'), | |
del = require('del'); | |
// Styles | |
gulp.task('styles', function() { | |
return gulp.src(['css/**/**.css']) | |
.pipe(order(['global.css', 'scrollbar.css', 'input-range.css', 'nav.css', 'overview.css', 'review.css', 'analyze.css', 'button.css'])) | |
.pipe(concatcss('styles.css')) | |
.pipe(autoprefixer({ | |
browsers: ['last 2 versions'], | |
cascade: false | |
})) | |
.pipe(rename({ | |
suffix: '.min' | |
})) | |
.pipe(minifycss()) | |
.pipe(gulp.dest('dist/styles')) | |
.pipe(notify({ | |
message: 'Styles task complete' | |
})); | |
}); | |
// Uncss | |
gulp.task('uncss', function() { | |
return gulp.src('bower_components/font-awesome/css/font-awesome.min.css') | |
.pipe(uncss({ | |
html: ['index.html', 'pages/**/*.html', 'templates/**/*.html'] | |
})) | |
.pipe(minifycss()) | |
.pipe(gulp.dest('css/uncss')); | |
}); | |
// Scripts | |
gulp.task('scripts', ['lint'], function() { | |
return gulp.src('js/**/*.js') | |
.pipe(concat('main.js')) | |
.pipe(rename({ | |
suffix: '.min' | |
})) | |
.pipe(uglify()) | |
.pipe(gulp.dest('dist/scripts')) | |
.pipe(notify({ | |
message: 'Scripts task complete' | |
})); | |
}); | |
// JSHint | |
gulp.task('lint', function() { | |
return gulp.src('js/**/*.js') | |
.pipe(jshint()) | |
.pipe(jshint.reporter('default')); | |
}); | |
// Templates | |
gulp.task('templates', function() { | |
gulp.src([ | |
'templates/**/*.html', | |
'pages/**/*.html' | |
]) | |
.pipe(minifyHTML({ | |
quotes: true | |
})) | |
.pipe(templates('templates.js', { | |
standalone: true | |
})) | |
.pipe(rename({ | |
suffix: '.min' | |
})) | |
.pipe(uglify()) | |
.pipe(gulp.dest('dist/scripts')); | |
}); | |
// Images | |
gulp.task('images', function() { | |
return gulp.src('img/**/*') | |
.pipe(cache(imagemin({ | |
optimizationLevel: 3, | |
progressive: true, | |
interlaced: true | |
}))) | |
.pipe(gulp.dest('dist/images')) | |
}); | |
// Watch | |
gulp.task('watch', function() { | |
gulp.watch('css/**/*.css', ['styles']); | |
gulp.watch('js/**/*.js', ['scripts']); | |
gulp.watch([ | |
'templates/**/*.html', | |
'pages/**/*.html' | |
], ['templates']) | |
}); | |
// Clean | |
gulp.task('clean', function() { | |
del(['dist/images', 'dist/scripts', 'dist/styles']); | |
}); | |
// Default task | |
gulp.task('default', function() { | |
gulp.start('styles', 'scripts', 'images'); | |
}); |
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
"devDependencies": { | |
"del": "~2.0.2", | |
"gulp": "~3.9.0", | |
"gulp-autoprefixer": "~3.0.2", | |
"gulp-cache": "~0.3.0", | |
"gulp-changed": "^1.3.0", | |
"gulp-concat": "~2.6.0", | |
"gulp-imagemin": "~2.3.0", | |
"gulp-jshint": "~1.11.2", | |
"gulp-minify-css": "~1.2.1", | |
"gulp-notify": "~2.2.0", | |
"gulp-order": "^1.1.1", | |
"gulp-rename": "~1.2.2", | |
"gulp-uglify": "~1.4.2", | |
"gulp-angular-templatecache": "^1.8.0", | |
"gulp-concat-css": "~2.2.0", | |
"gulp-minify-html": "^1.0.4", | |
"gulp-uncss": "^1.0.4" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment