fix gulp build
This commit is contained in:
parent
909edea62f
commit
cf26ed978a
28
gulpfile.js
28
gulpfile.js
|
@ -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']);
|
||||
|
|
Loading…
Reference in New Issue