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,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']);