-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.js
More file actions
78 lines (67 loc) · 2.09 KB
/
build.js
File metadata and controls
78 lines (67 loc) · 2.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
const fs = require("fs");
const path = require("path");
const gulp = require("gulp");
const include = require("gulp-include");
const handlebars = require("gulp-hb");
const sass = require("gulp-sass")(require("sass"));
const rename = require("gulp-rename");
//const hb_svg = require('handlebars-helper-svg');
const BUILDDIR = process.argv[2] || "./build/";
console.log("Building Pixel Editor");
function copy_images() {
// Icons
gulp.src("./images/*.png").pipe(gulp.dest(BUILDDIR));
//favicon
gulp.src("./images/*.ico").pipe(gulp.dest(BUILDDIR));
// Splash images
gulp.src("./images/Splash images/*.png").pipe(gulp.dest(BUILDDIR));
// Logs gifs
gulp.src("./images/Logs/*.gif").pipe(gulp.dest(BUILDDIR));
// Logs pngs
gulp.src("./images/Logs/*.png").pipe(gulp.dest(BUILDDIR));
// Tool tutorials
gulp.src("./images/ToolTutorials/*.gif").pipe(gulp.dest(BUILDDIR));
}
function copy_logs() {
gulp.src("logs/*.html").pipe(gulp.dest(BUILDDIR));
}
function render_js() {
gulp
.src("./js/pixel-editor.js")
.pipe(include({ includePaths: ["js", "!js/_*.js"] }))
.on("error", console.log)
.pipe(gulp.dest(BUILDDIR));
}
function render_css() {
gulp
.src("css/*.scss")
.pipe(sass({ includePaths: ["css"] }))
.pipe(gulp.dest(BUILDDIR));
}
function compile_page() {
gulp
.src(path.join("./views/index.hbs"))
.pipe(include({ includePaths: ["/svg"] }))
.pipe(
handlebars({ encoding: "utf8", debug: true, bustCache: true })
.partials("./views/[!index]*.hbs")
.partials("./views/popups/*.hbs")
.partials("./views/components/*.hbs")
.helpers("./helpers/**/*.js")
.data({
projectSlug: "pixel-editor",
title: "Pixel Editor",
layout: false,
})
)
.pipe(rename("index.html"))
.pipe(gulp.dest(BUILDDIR));
}
// empty the build folder, or create it
try {
fs.rmdirSync(BUILDDIR, { recursive: true });
fs.mkdirSync(BUILDDIR);
} catch (err) {
console.log("failed to find build folder, but it's probably fine");
}
gulp.parallel(copy_images, copy_logs, render_js, render_css, compile_page)();