2020-03-06 07:29:02 +03:00
|
|
|
/* global $, fetch, console */
|
|
|
|
/* eslint no-undef: "error", semi: 2 */
|
|
|
|
|
|
|
|
'use strict';
|
|
|
|
|
|
|
|
const {
|
|
|
|
src,
|
|
|
|
dest,
|
|
|
|
parallel,
|
|
|
|
series,
|
|
|
|
watch
|
|
|
|
} = require('gulp');
|
|
|
|
|
2020-12-19 08:02:00 +03:00
|
|
|
const htmlmin = require('gulp-htmlmin');
|
2020-03-06 07:29:02 +03:00
|
|
|
const inlinesource = require('gulp-inline-source');
|
2020-12-19 08:02:00 +03:00
|
|
|
const rename = require('gulp-rename');
|
|
|
|
const browserSync = require('browser-sync').create();
|
2023-02-26 08:12:58 +03:00
|
|
|
const sass = require('gulp-sass')(require('sass'));
|
2020-03-06 07:29:02 +03:00
|
|
|
|
|
|
|
function sassCompile () {
|
2023-02-26 08:12:58 +03:00
|
|
|
return src('./sass/**/main.scss')
|
2020-03-06 07:29:02 +03:00
|
|
|
.pipe(sass({ outputStyle: 'compressed' }).on('error', sass.logError))
|
|
|
|
.pipe(rename('main.min.css'))
|
2023-02-26 08:12:58 +03:00
|
|
|
.pipe(dest('./css'));
|
2020-03-06 07:29:02 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
function minify () {
|
2023-02-26 08:12:58 +03:00
|
|
|
return src('./*.src.html')
|
2020-03-06 07:29:02 +03:00
|
|
|
.pipe(inlinesource())
|
|
|
|
.pipe(htmlmin({
|
|
|
|
collapseWhitespace: true
|
|
|
|
}))
|
|
|
|
.pipe(rename('index.html'))
|
2023-02-26 08:12:58 +03:00
|
|
|
.pipe(dest('./'));
|
2020-03-06 07:29:02 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
function serve () {
|
|
|
|
browserSync.init({
|
|
|
|
port: 8890,
|
|
|
|
reloadDelay: 500,
|
|
|
|
ui: false,
|
|
|
|
open: true,
|
|
|
|
server: {
|
|
|
|
baseDir: './',
|
|
|
|
directory: true
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
function reload (done) {
|
|
|
|
browserSync.reload();
|
|
|
|
done();
|
|
|
|
}
|
|
|
|
|
|
|
|
function watchFiles () {
|
2023-02-26 08:12:58 +03:00
|
|
|
watch(['./**/*.html', '!./index.html'], series(sassCompile, minify, reload));
|
|
|
|
watch(['./js/**/*.js'], series(sassCompile, minify, reload));
|
|
|
|
watch(['./sass/**/*.scss'], series(sassCompile, minify, reload));
|
2020-03-06 07:29:02 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
exports.default = parallel(serve, watchFiles);
|
|
|
|
exports.dev = parallel(serve, watchFiles);
|