1
0
mirror of https://github.com/Mayccoll/Gogh.git synced 2023-08-10 21:12:46 +03:00
Gogh/gh-pages/gulpfile.js

63 lines
1.4 KiB
JavaScript
Raw Normal View History

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');
const htmlmin = require('gulp-htmlmin');
2020-03-06 07:29:02 +03:00
const inlinesource = require('gulp-inline-source');
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);