fix gulp build

This commit is contained in:
Jakub Sokołowski 2018-08-10 23:59:10 -04:00
parent 909edea62f
commit cf26ed978a
No known key found for this signature in database
GPG Key ID: 4EF064D0E6D63020
1 changed files with 37 additions and 39 deletions

View File

@ -17,27 +17,15 @@ var uglify = require('gulp-uglify');
var imagemin = require('gulp-imagemin');
gulp.task('serve', ['sass', 'imagemin', 'js'], function() {
browserSync.init({
server: "./"
})
gulp.watch("src/scss/*.scss", ['sass']);
gulp.watch("src/js/*.js", ['js']);
gulp.watch("src/img/**/*", ['imagemin']);
gulp.watch("./*.html").on('change', browserSync.reload);
})
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'] })))
.pipe(streamify(babel({ presets: ['es2015', 'es2017'] })))
.pipe(buffer())
.pipe(sourcemaps.init({loadMaps: true}))
.pipe(uglify())
.pipe(sourcemaps.write('./'))
.pipe(gulp.dest('dist'))
@ -63,4 +51,14 @@ gulp.task('cleanUp', function() {
del.sync('dist/*')
})
gulp.task('default', ['cleanUp', 'serve']);
gulp.task('serve', ['build'], function() {
browserSync.init({server: "./"})
gulp.watch("src/scss/*.scss", ['sass']);
gulp.watch("src/js/*.js", ['js']);
gulp.watch("src/img/**/*", ['imagemin']);
gulp.watch("./*.html").on('change', browserSync.reload);
})
gulp.task('build', ['cleanUp', 'sass', 'imagemin', 'js']);
gulp.task('default', ['serve']);