Created
November 5, 2015 01:11
-
-
Save sl-digital/f79ea3de0dd582f59378 to your computer and use it in GitHub Desktop.
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
/** | |
* Setup: | |
* 1) Install Node/NPM Globally (https://nodejs.org/) | |
* 2) Install Gulp and Gulp Modules | |
* | |
* Run these commands in Terminal after installing Node: | |
* 1) sudo npm install --global gulp | |
* 2) npm install gulp gulp-jshint gulp-sass gulp-autoprefixer gulp-minify-css gulp-uglify gulp-imagemin imagemin-pngquant gulp-rename gulp-watch gulp-notify --save-dev | |
**/ | |
var gulp = require('gulp'); | |
var jshint = require('gulp-jshint'); | |
var sass = require('gulp-sass'); | |
var autoprefixer = require('gulp-autoprefixer'); | |
var mincss = require('gulp-minify-css'); | |
var minjs = require('gulp-uglify'); | |
var imagemin = require('gulp-imagemin'); | |
var pngquant = require('imagemin-pngquant'); | |
var rename = require('gulp-rename'); | |
var watch = require('gulp-watch'); | |
var notify = require('gulp-notify'); | |
var project = "./project_folder/"; | |
//.pipe(autoprefixer({browsers:['last 10 versions'],cascade:false})) | |
gulp.task('compile-css',function(){ | |
return gulp.src(project + 'src/sass/**/*.scss') | |
.pipe(sass({errLogToConsole:true})) | |
.pipe(gulp.dest(project + 'dist/assets/css/')) | |
.pipe(mincss()) | |
.pipe(rename({extname:'.min.css'})) | |
.pipe(gulp.dest(project + 'dist/assets/css/')) | |
.pipe(notify('CSS saved to distribution')); | |
}); | |
gulp.task('compile-js',function(){ | |
return gulp.src(project + 'src/js/**/*.js') | |
.pipe(jshint()) | |
.pipe(jshint.reporter('default')) | |
.pipe(gulp.dest(project + 'dist/assets/js/')) | |
.pipe(minjs()) | |
.pipe(rename({extname:'.min.js'})) | |
.pipe(gulp.dest(project + 'dist/assets/js/')) | |
.pipe(notify('JS saved to distribution')); | |
}); | |
gulp.task('compile-img',function(){ | |
return gulp.src(project + 'src/img/**/*') | |
.pipe(imagemin({ | |
progressive: false, | |
svgoPlugins: [{removeViewBox:false}], | |
use: [pngquant()] | |
})) | |
.pipe(gulp.dest(project + 'dist/assets/img')) | |
.pipe(notify('Images saved to distribution')); | |
}); | |
gulp.task('watch',function(){ | |
watch([project + 'src/sass/**/*.scss'],function(){ gulp.start('compile-css'); }); | |
watch([project + 'src/js/**/*.js'],function(){ gulp.start('compile-js'); }); | |
watch([project + 'src/img/**/*'],function(){ gulp.start('compile-img'); }); | |
}); | |
gulp.task('build',['compile-css','compile-js','compile-img']); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment