2023-03-01 06:12:17 -05:00
|
|
|
const path = require("path");
|
2021-08-14 12:12:42 -05:00
|
|
|
const gulp = require("gulp");
|
|
|
|
const postcss = require("gulp-postcss");
|
|
|
|
const sass = require("gulp-sass")(require("sass"));
|
|
|
|
const sourcemaps = require("gulp-sourcemaps");
|
|
|
|
const terser = require("gulp-terser");
|
2020-09-23 09:08:21 -05:00
|
|
|
|
2023-03-01 06:12:17 -05:00
|
|
|
const SOURCE_DIR = path.resolve(__dirname, "src");
|
|
|
|
const OUTPUT_DIR = path.resolve(__dirname, "public");
|
2021-08-27 08:13:50 -05:00
|
|
|
|
2020-09-23 09:08:21 -05:00
|
|
|
function html() {
|
2023-03-01 06:12:17 -05:00
|
|
|
return gulp
|
|
|
|
.src(path.join(SOURCE_DIR, "index.html"))
|
|
|
|
.pipe(gulp.dest(OUTPUT_DIR));
|
2020-09-23 09:08:21 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
function css() {
|
2021-08-14 12:12:42 -05:00
|
|
|
return gulp
|
2023-03-01 06:12:17 -05:00
|
|
|
.src(path.join(SOURCE_DIR, "scss", "*.scss"))
|
2021-08-14 11:49:32 -05:00
|
|
|
.pipe(sourcemaps.init())
|
2021-08-14 12:12:42 -05:00
|
|
|
.pipe(sass.sync().on("error", sass.logError))
|
2021-08-14 11:49:32 -05:00
|
|
|
.pipe(postcss([require("autoprefixer"), require("postcss-csso")]))
|
2021-08-14 12:12:42 -05:00
|
|
|
.pipe(sourcemaps.write("."))
|
2021-08-27 08:13:50 -05:00
|
|
|
.pipe(gulp.dest(OUTPUT_DIR));
|
2020-09-23 09:08:21 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
function js() {
|
2021-08-14 12:12:42 -05:00
|
|
|
return gulp
|
2023-03-01 06:12:17 -05:00
|
|
|
.src([path.join(SOURCE_DIR, "main.js"), path.join(SOURCE_DIR, "count.js")])
|
2021-08-14 11:54:32 -05:00
|
|
|
.pipe(sourcemaps.init())
|
2021-01-29 16:56:37 -05:00
|
|
|
.pipe(terser({ ecma: 5 }))
|
2021-08-14 12:12:42 -05:00
|
|
|
.pipe(sourcemaps.write("."))
|
2021-08-27 08:13:50 -05:00
|
|
|
.pipe(gulp.dest(OUTPUT_DIR));
|
2020-09-23 09:08:21 -05:00
|
|
|
}
|
|
|
|
|
2023-03-01 06:12:17 -05:00
|
|
|
function staticFiles() {
|
2021-08-27 08:13:50 -05:00
|
|
|
return gulp
|
2023-03-01 06:12:17 -05:00
|
|
|
.src(path.join(SOURCE_DIR, "static", "**", "*"))
|
2021-08-27 08:13:50 -05:00
|
|
|
.pipe(gulp.dest(OUTPUT_DIR));
|
2020-09-23 12:13:50 -05:00
|
|
|
}
|
|
|
|
|
2023-03-01 06:12:17 -05:00
|
|
|
exports.default = gulp.parallel(html, css, js, staticFiles);
|
2020-09-23 09:08:21 -05:00
|
|
|
|
|
|
|
exports.watch = () => {
|
2023-03-01 06:12:17 -05:00
|
|
|
gulp.watch(path.join(SOURCE_DIR, "index.html"), html);
|
|
|
|
gulp.watch(path.join(SOURCE_DIR, "scss", "*.scss"), css);
|
|
|
|
gulp.watch(path.join(SOURCE_DIR, "*.js"), js);
|
|
|
|
gulp.watch(path.join(SOURCE_DIR, "static", "**", "*"), staticFiles);
|
2021-08-14 12:12:42 -05:00
|
|
|
};
|