mailymaily/gulpfile.js

57 lines
1.4 KiB
JavaScript
Raw Normal View History

2020-08-29 11:55:43 +00:00
const { src, dest, parallel, series, watch } = require('gulp');
const autoprefixer = require('gulp-autoprefixer');
const minify = require('gulp-minify');
const cleanCss = require('gulp-clean-css');
const rename = require('gulp-rename');
const fs = require('fs-extra');
const htmlMin = require('gulp-htmlmin');
const sass = require('gulp-sass');
/**
* Process HTML files.
*/
function html() {
2020-08-29 14:25:32 +00:00
return src('./src/html/component.html')
.pipe(htmlMin({ collapseWhitespace: true }))
.pipe(rename('./src/html/component-min.html'))
.pipe(dest('./'));
2020-08-29 11:55:43 +00:00
}
/**
* Process CSS file.
*/
function css() {
2020-08-29 14:25:32 +00:00
return src('./src/scss/component.scss')
.pipe(sass())
.pipe(autoprefixer())
.pipe(cleanCss())
.pipe(rename('./src/css/component-min.css'))
.pipe(dest('./'));
2020-08-29 11:55:43 +00:00
}
/**
* Process the JavaScript library file.
*/
function js() {
2020-08-29 14:25:32 +00:00
packageJson = fs.readJsonSync('./package.json');
2020-08-29 11:55:43 +00:00
2020-08-29 14:25:32 +00:00
return src('./src/js/mailymaily.js').pipe(minify({ noSource: true })).pipe(dest('dist'));
2020-08-29 11:55:43 +00:00
}
/**
* The all seeing eye...
*/
function watchFiles() {
2020-08-29 14:25:32 +00:00
watch('./src/html/component.html', html);
watch('./src/scss/component.scss', css);
watch([ './src/js/mailymaily.js', './package.json' ]);
2020-08-29 11:55:43 +00:00
}
2020-08-29 12:02:59 +00:00
const build = series(parallel(html, css), js);
2020-08-29 11:55:43 +00:00
const watching = series(build, watchFiles);
2020-08-29 14:25:32 +00:00
//-----
2020-08-29 11:55:43 +00:00
exports.html = html;
exports.css = css;
exports.js = js;
exports.watch = watching;
exports.default = build;