From cf26ed978a76e8dd689b1f9e9ea395147d3166cc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Soko=C5=82owski?= Date: Fri, 10 Aug 2018 23:59:10 -0400 Subject: [PATCH] fix gulp build --- gulpfile.js | 76 ++++++++++++++++++++++++++--------------------------- 1 file changed, 37 insertions(+), 39 deletions(-) diff --git a/gulpfile.js b/gulpfile.js index e7f9958..a595aa3 100755 --- a/gulpfile.js +++ b/gulpfile.js @@ -17,11 +17,42 @@ var uglify = require('gulp-uglify'); var imagemin = require('gulp-imagemin'); -gulp.task('serve', ['sass', 'imagemin', 'js'], function() { +gulp.task('js', function () { + return gulp.src('src/**/*.js', {read: false}) + .pipe(sourcemaps.init({loadMaps: true})) + .pipe(tap(function (file) { + gutil.log('bundling ' + file.path) + file.contents = browserify(file.path, {debug: true}).bundle() + })) + .pipe(streamify(babel({ presets: ['es2015', 'es2017'] }))) + .pipe(buffer()) + .pipe(uglify()) + .pipe(sourcemaps.write('./')) + .pipe(gulp.dest('dist')) + .pipe(browserSync.stream()); +}) - browserSync.init({ - server: "./" - }) +gulp.task('sass', function() { + return gulp.src("src/scss/main.scss") + .pipe(sass()) + .on('error', gutil.log) + .pipe(autoprefixer({ browsers: ['last 3 versions'], cascade: false })) + .pipe(gulp.dest("dist/css")) + .pipe(browserSync.stream()); +}) + +gulp.task('imagemin', function() { + gulp.src('src/img/**/*') + .pipe(imagemin()) + .pipe(gulp.dest('dist/img')) +}) + +gulp.task('cleanUp', function() { + del.sync('dist/*') +}) + +gulp.task('serve', ['build'], function() { + browserSync.init({server: "./"}) gulp.watch("src/scss/*.scss", ['sass']); gulp.watch("src/js/*.js", ['js']); @@ -29,38 +60,5 @@ gulp.task('serve', ['sass', 'imagemin', 'js'], function() { gulp.watch("./*.html").on('change', browserSync.reload); }) -gulp.task('js', function () { - return gulp.src('src/**/*.js', {read: false}) - .pipe(tap(function (file) { - gutil.log('bundling ' + file.path) - file.contents = browserify(file.path, {debug: true}).bundle() - })) - .pipe(streamify(babel({ presets: ['es2015'] }))) - .pipe(buffer()) - .pipe(sourcemaps.init({loadMaps: true})) - .pipe(uglify()) - .pipe(sourcemaps.write('./')) - .pipe(gulp.dest('dist')) - .pipe(browserSync.stream()); -}) - -gulp.task('sass', function() { - return gulp.src("src/scss/main.scss") - .pipe(sass()) - .on('error', gutil.log) - .pipe(autoprefixer({ browsers: ['last 3 versions'], cascade: false })) - .pipe(gulp.dest("dist/css")) - .pipe(browserSync.stream()); -}) - -gulp.task('imagemin', function() { - gulp.src('src/img/**/*') - .pipe(imagemin()) - .pipe(gulp.dest('dist/img')) -}) - -gulp.task('cleanUp', function() { - del.sync('dist/*') -}) - -gulp.task('default', ['cleanUp', 'serve']); +gulp.task('build', ['cleanUp', 'sass', 'imagemin', 'js']); +gulp.task('default', ['serve']);