Created
August 11, 2015 02:36
-
-
Save joepreludian/145efc7f412509d5dc20 to your computer and use it in GitHub Desktop.
GULP Stuff - Useful when working with coffeescript and sass
This file contains hidden or 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
| var gulp = require('gulp'), | |
| plumber = require('gulp-plumber'), | |
| rename = require('gulp-rename'); | |
| var autoprefixer = require('gulp-autoprefixer'); | |
| var coffee = require('gulp-coffee'); | |
| var concat = require('gulp-concat'); | |
| var uglify = require('gulp-uglify'); | |
| var imagemin = require('gulp-imagemin'), | |
| cache = require('gulp-cache'); | |
| var minifycss = require('gulp-minify-css'); | |
| var sass = require('gulp-sass'); | |
| var browserSync = require('browser-sync'); | |
| gulp.task('browser-sync', function() { | |
| browserSync({ | |
| server: { | |
| baseDir: "./" | |
| } | |
| }); | |
| }); | |
| gulp.task('bs-reload', function () { | |
| browserSync.reload(); | |
| }); | |
| gulp.task('images', function(){ | |
| gulp.src('src/imgs/**/*') | |
| .pipe(cache(imagemin({ optimizationLevel: 3, progressive: true, interlaced: true }))) | |
| .pipe(gulp.dest('dist/imgs/')); | |
| }); | |
| gulp.task('styles', function(){ | |
| gulp.src(['src/sass/**/*.scss']) | |
| .pipe(plumber({ | |
| errorHandler: function (error) { | |
| console.log(error.message); | |
| this.emit('end'); | |
| }})) | |
| .pipe(sass()) | |
| .pipe(autoprefixer('last 2 versions')) | |
| .pipe(gulp.dest('dist/css/')) | |
| .pipe(rename({suffix: '.min'})) | |
| .pipe(minifycss()) | |
| .pipe(gulp.dest('dist/css/')) | |
| .pipe(browserSync.reload({stream:true})) | |
| }); | |
| gulp.task('scripts', function(){ | |
| return gulp.src('src/coffee/**/*.coffee') | |
| .pipe(plumber({ | |
| errorHandler: function (error) { | |
| console.log(error.message); | |
| this.emit('end'); | |
| }})) | |
| .pipe(coffee({bare: true})) | |
| .pipe(concat('main.js')) | |
| .pipe(gulp.dest('dist/js/')) | |
| .pipe(rename({suffix: '.min'})) | |
| .pipe(uglify()) | |
| .pipe(gulp.dest('dist/js/')) | |
| .pipe(browserSync.reload({stream:true})); | |
| }); | |
| gulp.task('default', ['browser-sync'], function(){ | |
| gulp.watch("src/sass/**/*.scss", ['styles']); | |
| gulp.watch("src/coffee/**/*.coffee", ['scripts']); | |
| gulp.watch("*.html", ['bs-reload']); | |
| }); |
This file contains hidden or 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
| { | |
| "name": "sample_project", | |
| "version": "1.0.0", | |
| "description": "Dev Assets", | |
| "main": "gulpfile.js", | |
| "scripts": { | |
| "test": "echo \"Error: no test specified\" && exit 1" | |
| }, | |
| "author": "Quench", | |
| "license": "ISC", | |
| "devDependencies": { | |
| "browser-sync": "2.6.5", | |
| "gulp-autoprefixer": "2.1.0", | |
| "gulp-cache": "0.2.8", | |
| "gulp-concat": "2.5.2", | |
| "gulp-imagemin": "2.2.1", | |
| "gulp-minify-css": "1.0.0", | |
| "gulp-plumber": "1.0.0", | |
| "gulp-rename": "1.2.2", | |
| "gulp-sass": "1.3.3", | |
| "gulp-uglify": "1.2.0", | |
| "gulp": "3.8.11", | |
| "gulp-coffee": "~2.3.1" | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment