Skip to content

Commit

Permalink
gulp fix
Browse files Browse the repository at this point in the history
  • Loading branch information
forkineye committed Jun 20, 2024
1 parent 28e2ecd commit 3aed714
Showing 1 changed file with 102 additions and 73 deletions.
175 changes: 102 additions & 73 deletions gulpfile.mjs
Original file line number Diff line number Diff line change
@@ -1,104 +1,133 @@
/* Imports */
import gulp from 'gulp';
import gulp from "gulp";
const { series, parallel, src, dest, task } = gulp;
import plumber from 'gulp-plumber';
import concat from 'gulp-concat';
import htmlmin from 'gulp-htmlmin';
import cleancss from 'gulp-clean-css';
import terser from 'gulp-terser';
import gzip from 'gulp-gzip';
import { deleteAsync } from 'del';
import markdown from 'gulp-markdown-github-style';
import rename from 'gulp-rename';
import plumber from "gulp-plumber";
import concat from "gulp-concat";
import htmlmin from "gulp-htmlmin";
import cleancss from "gulp-clean-css";
import terser from "gulp-terser";
import gzip from "gulp-gzip";
import { deleteAsync } from "del";
import markdown from "gulp-markdown-github-style";
import rename from "gulp-rename";

/* HTML Task */
gulp.task('html', function() {
return gulp.src(['html/*.html'])
.pipe(plumber())
.pipe(htmlmin({
collapseWhitespace: true,
removeComments: true,
minifyCSS: true,
minifyJS: true}))
.pipe(gzip())
.pipe(gulp.dest('ESPixelStick/data/www'));
gulp.task("html", function () {
return gulp
.src(["html/*.html"])
.pipe(plumber())
.pipe(
htmlmin({
collapseWhitespace: true,
removeComments: true,
minifyCSS: true,
minifyJS: true,
})
)
.pipe(gzip())
.pipe(gulp.dest("ESPixelStick/data/www"));
});

/* CSS Task */
gulp.task('css', function() {
return gulp.src(['html/css/bootstrap.css', 'html/css/dropzone.css', 'html/css/style.css'])
.pipe(plumber())
.pipe(concat('esps.css'))
.pipe(cleancss())
.pipe(gzip())
.pipe(gulp.dest('ESPixelStick/data/www'));
gulp.task("css", function () {
return gulp
.src([
"html/css/bootstrap.css",
"html/css/dropzone.css",
"html/css/style.css",
])
.pipe(plumber())
.pipe(concat("esps.css"))
.pipe(cleancss())
.pipe(gzip())
.pipe(gulp.dest("ESPixelStick/data/www"));
});

/* JavaScript Task */
gulp.task('js', function() {
return gulp.src(['html/js/jquery*.js', 'html/js/bootstrap.js', 'html/js/jqColorPicker.js', 'html/js/dropzone.js', 'html/js/FileSaver.js', 'html/js/jquery.cookie.js', 'html/script.js'])
.pipe(plumber())
.pipe(concat('esps.js'))
.pipe(terser({ 'toplevel': true })) /* comment out this line to debug the script file */
.pipe(gzip())
.pipe(gulp.dest('ESPixelStick/data/www'));
gulp.task("js", function () {
return gulp
.src([
"html/js/jquery-*.js",
"html/js/bootstrap.js",
"html/js/jqColorPicker.js",
"html/js/dropzone.js",
"html/js/FileSaver.js",
"html/js/jquery.cookie.js",
"html/script.js",
])
.pipe(plumber())
.pipe(concat("esps.js"))
.pipe(
terser({ toplevel: true })
) /* comment out this line to debug the script file */
.pipe(gzip())
.pipe(gulp.dest("ESPixelStick/data/www"));
});

/* json Task */
gulp.task('json', function() {
return gulp.src('html/*.json')
.pipe(plumber())
.pipe(gulp.dest('ESPixelStick/data'));
gulp.task("json", function () {
return gulp
.src("html/*.json")
.pipe(plumber())
.pipe(gulp.dest("ESPixelStick/data"));
});

/* Image Task */
gulp.task('image', function() {
return gulp.src(['html/**/*.png', 'html/**/*.ico'])
.pipe(plumber())
.pipe(gulp.dest('ESPixelStick/data/www'));
gulp.task("image", function () {
return gulp
.src(["html/**/*.png", "html/**/*.ico"])
.pipe(plumber())
.pipe(gulp.dest("ESPixelStick/data/www"));
});

/* Clean Task */
gulp.task('clean', function() {
return deleteAsync(['ESPixelStick/data/www/*']);
gulp.task("clean", function () {
return deleteAsync(["ESPixelStick/data/www/*"]);
});

/* Markdown to HTML Task */
gulp.task('md', function(done) {
gulp.src('README.md')
.pipe(plumber())
.pipe(rename('ESPixelStick.html'))
.pipe(markdown())
.pipe(gulp.dest('dist'));
gulp.src('Changelog.md')
.pipe(plumber())
.pipe(rename('Changelog.html'))
.pipe(markdown())
.pipe(gulp.dest('dist'));
gulp.src('dist/README.md')
.pipe(plumber())
.pipe(rename('README.html'))
.pipe(markdown())
.pipe(gulp.dest('dist'));
done();
gulp.task("md", function (done) {
gulp
.src("README.md")
.pipe(plumber())
.pipe(rename("ESPixelStick.html"))
.pipe(markdown())
.pipe(gulp.dest("dist"));
gulp
.src("Changelog.md")
.pipe(plumber())
.pipe(rename("Changelog.html"))
.pipe(markdown())
.pipe(gulp.dest("dist"));
gulp
.src("dist/README.md")
.pipe(plumber())
.pipe(rename("README.html"))
.pipe(markdown())
.pipe(gulp.dest("dist"));
done();
});

/* CI specific stuff */
gulp.task('ci', function(done) {
gulp.src(['.ci/warning.md', 'dist/README.md'])
.pipe(plumber())
.pipe(concat('README.html'))
.pipe(markdown())
.pipe(gulp.dest('dist'));
done();
gulp.task("ci", function (done) {
gulp
.src([".ci/warning.md", "dist/README.md"])
.pipe(plumber())
.pipe(concat("README.html"))
.pipe(markdown())
.pipe(gulp.dest("dist"));
done();
});

/* Watch Task */
gulp.task('watch', function() {
gulp.watch('html/*.html', gulp.series('html'));
gulp.watch('html/**/*.css', gulp.series('css'));
gulp.watch('html/**/*.js', gulp.series('js'));
gulp.task("watch", function () {
gulp.watch("html/*.html", gulp.series("html"));
gulp.watch("html/**/*.css", gulp.series("css"));
gulp.watch("html/**/*.js", gulp.series("js"));
});

/* Default Task */
gulp.task('default', gulp.series(['clean', 'html', 'css', 'js', 'image', 'json']));
gulp.task(
"default",
gulp.series(["clean", "html", "css", "js", "image", "json"])
);

0 comments on commit 3aed714

Please sign in to comment.