2018-09-22 19:55:26 +03:00
|
|
|
'use strict';
|
|
|
|
|
2018-12-06 19:47:21 +03:00
|
|
|
const gulp = require('gulp');
|
2018-09-22 19:55:26 +03:00
|
|
|
|
2018-12-06 19:47:21 +03:00
|
|
|
const htmlmin = require('gulp-htmlmin');
|
|
|
|
const inlinesource = require('gulp-inline-source');
|
|
|
|
const rename = require("gulp-rename");
|
|
|
|
const browserSync = require('browser-sync').create();
|
|
|
|
|
|
|
|
|
|
|
|
gulp.task('minify', () => {
|
|
|
|
return gulp.src('./*.src.html')
|
|
|
|
.pipe(inlinesource())
|
|
|
|
.pipe(htmlmin({ collapseWhitespace: true }))
|
|
|
|
.pipe(rename("index.html"))
|
|
|
|
.pipe(gulp.dest('./'));
|
|
|
|
});
|
2018-09-22 19:55:26 +03:00
|
|
|
|
|
|
|
gulp.task('serve', function () {
|
|
|
|
browserSync.init({
|
|
|
|
port: 8890,
|
|
|
|
reloadDelay: 500,
|
|
|
|
ui: false,
|
|
|
|
open: true,
|
|
|
|
server: {
|
|
|
|
baseDir: './',
|
|
|
|
directory: true
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
gulp.task('reload', function (done) {
|
|
|
|
browserSync.reload();
|
|
|
|
done();
|
|
|
|
});
|
|
|
|
|
|
|
|
gulp.task('watch', ['serve'], function () {
|
2018-12-06 19:47:21 +03:00
|
|
|
gulp.watch(['./**/*', '!./index.html'], { interval: 800 }, ['minify', 'reload']);
|
2018-09-22 19:55:26 +03:00
|
|
|
});
|
|
|
|
|
|
|
|
gulp.task('default', ['watch']);
|
|
|
|
|
2018-12-06 19:47:21 +03:00
|
|
|
gulp.task('dev', ['watch']);
|