Created
May 17, 2016 12:03
-
-
Save Dubiy/07c52ec723ab5653448799c7910c30dc 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
var gulp = require('gulp'), | |
concat = require('gulp-concat'), | |
uglify = require('gulp-uglify'), | |
autoprefixer = require('gulp-autoprefixer'), | |
sass = require('gulp-sass'), | |
minifyCss = require('gulp-minify-css'), | |
del = require('del'), | |
imagemin = require('gulp-imagemin'), | |
sourcemaps = require('gulp-sourcemaps'), | |
babel = require('gulp-babel'), | |
browserSync = require('browser-sync').create(), | |
util = require('gulp-util'); | |
gulp.task('default', ['clean'], function() { | |
gulp.start('fonts', 'css', 'templates', 'scss', 'js', 'images', 'scripts'); | |
}); | |
gulp.task('clean', function () { | |
del(['scss', 'js', 'images']); | |
}); | |
gulp.task('scss', function () { | |
return gulp.src('web-src/scss/*.scss') | |
.pipe(sourcemaps.init('')) | |
.pipe(sass().on('error', sass.logError)) | |
.on('error', browserifyHandler) | |
.pipe(autoprefixer()) | |
.pipe(minifyCss({ | |
keepSpecialComments: 0 | |
})) | |
.pipe(sourcemaps.write('')) | |
.pipe(gulp.dest('web/scss')) | |
.pipe(browserSync.stream()); | |
}); | |
gulp.task('images', function () { | |
return gulp.src(['web-src/images/*']) | |
.pipe(imagemin({ | |
progressive: true, | |
interlaced: true | |
})) | |
.pipe(gulp.dest('web/images/')) | |
.pipe(browserSync.stream()); | |
}); | |
gulp.task('scripts', function() { | |
return gulp.src(['web-src/js/*.js']) | |
.pipe(sourcemaps.init()) | |
.pipe(babel()) | |
.on('error', browserifyHandler) | |
.on('error', browserifyHandler) | |
.pipe(concat('app.js')) | |
.pipe(uglify()) | |
.pipe(sourcemaps.write(".")) | |
.pipe(gulp.dest('web/js/')) | |
.pipe(browserSync.stream()); | |
}); | |
function browserifyHandler(err) { | |
util.log(util.colors.red('Error: ' + err.message)); | |
this.end(); | |
} | |
gulp.task('watch', function () { | |
var css = gulp.watch('web-src/scss/*.scss', ['scss']), | |
templates = gulp.watch('web-src/templates/*', ['templates']), | |
js = gulp.watch('web-src/js/*', ['scripts']); | |
}); | |
gulp.task('fonts', function () { | |
return gulp.src([ | |
'bower_components/bootstrap/fonts/*', | |
'bower_components/font-awesome/fonts/*', | |
'bower_components/font-awesome/css/*' | |
]) | |
.pipe(gulp.dest('web/fonts/')) | |
}); | |
gulp.task('templates', function () { | |
return gulp.src([ | |
'web-src/templates/*' | |
]) | |
.pipe(gulp.dest('web/templates/')) | |
}); | |
gulp.task('css', function () { | |
return gulp.src([ | |
'bower_components/bootstrap/dist/css/bootstrap.min.css', | |
'bower_components/bootstrap/dist/css/bootstrap-theme.min.css' | |
]) | |
.pipe(gulp.dest('web/css/')) | |
}); | |
gulp.task('js', function () { | |
return gulp.src([ | |
'bower_components/angular/angular.min.js', | |
'bower_components/angular-contenteditable/angular-contenteditable.js', | |
'bower_components/ngDraggable/ngDraggable.js', | |
'bower_components/jquery/dist/jquery.min.js', | |
'bower_components/bootstrap/dist/js/bootstrap.min.js' | |
]) | |
.pipe(concat('vendor.js')) | |
.pipe(gulp.dest('web/js/')); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment