2020-04-04 18:43:31 +03:00
|
|
|
const fs = require('fs');
|
2020-04-04 10:36:08 +03:00
|
|
|
const path = require('path');
|
|
|
|
const gulp = require('gulp');
|
|
|
|
const include = require('gulp-include');
|
2020-04-04 18:43:31 +03:00
|
|
|
const hb = require('gulp-hb');
|
|
|
|
const sass = require('gulp-sass');
|
|
|
|
const rename = require('gulp-rename');
|
|
|
|
|
|
|
|
const hb_svg = require('handlebars-helper-svg');
|
2020-04-04 10:36:08 +03:00
|
|
|
|
|
|
|
const BUILDDIR = process.argv[2] || './build/';
|
2019-03-28 05:19:15 +03:00
|
|
|
const SLUG = 'pixel-editor';
|
2019-03-27 02:20:54 +03:00
|
|
|
|
2019-03-28 05:19:15 +03:00
|
|
|
console.log('Building Pixel Editor');
|
2019-03-27 02:20:54 +03:00
|
|
|
|
|
|
|
|
2020-04-04 18:43:31 +03:00
|
|
|
function copy_images(){
|
2021-04-27 14:00:43 +03:00
|
|
|
// Icons
|
|
|
|
gulp.src('./images/*.png').pipe(gulp.dest(path.join(BUILDDIR, SLUG)));
|
|
|
|
// Splash images
|
|
|
|
gulp.src('./images/Splash images/*.png').pipe(gulp.dest(path.join(BUILDDIR, SLUG)));
|
2021-04-29 00:39:14 +03:00
|
|
|
// Logs images
|
|
|
|
gulp.src('./images/Logs/*.gif').pipe(gulp.dest(path.join(BUILDDIR, SLUG)));
|
2021-04-27 14:00:43 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
function copy_logs() {
|
|
|
|
gulp.src('logs/*.html').pipe(gulp.dest(path.join(BUILDDIR, SLUG)));
|
2020-04-04 18:43:31 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
function render_js(){
|
|
|
|
gulp.src('./js/*.js')
|
|
|
|
.pipe(include({includePaths: [
|
|
|
|
'_ext/scripts',
|
|
|
|
'js',
|
|
|
|
'!js/_*.js',
|
|
|
|
]}))
|
|
|
|
.on('error', console.log)
|
|
|
|
.pipe(gulp.dest(path.join(BUILDDIR, SLUG)));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function render_css(){
|
|
|
|
gulp.src('css/*.scss')
|
|
|
|
.pipe(sass({includePaths: ['css', '_ext/sass', '_ext/modules/css']}))
|
|
|
|
.pipe(gulp.dest(path.join(BUILDDIR, SLUG)));
|
|
|
|
}
|
|
|
|
|
|
|
|
function compile_page(){
|
|
|
|
gulp.src(path.join('./views/', SLUG + '.hbs'))
|
|
|
|
.pipe(hb({encoding: 'utf8'})
|
|
|
|
.partials('./_ext/modules/_*.hbs')
|
|
|
|
.helpers({ svg: hb_svg })
|
|
|
|
.helpers('./_ext/modules/hbs/helpers/**/*.js')
|
|
|
|
.data({
|
|
|
|
projectSlug: SLUG,
|
|
|
|
title: 'Lospec Pixel Editor',
|
|
|
|
layout: false,
|
|
|
|
}))
|
|
|
|
.pipe(rename('index.htm'))
|
|
|
|
.pipe(gulp.dest(BUILDDIR));
|
|
|
|
}
|
2019-03-27 02:20:54 +03:00
|
|
|
|
|
|
|
|
2020-04-04 18:43:31 +03:00
|
|
|
// empty the build folder, or create it
|
|
|
|
fs.rmdirSync(BUILDDIR, { recursive: true });
|
|
|
|
fs.mkdirSync(BUILDDIR);
|
2021-04-27 14:00:43 +03:00
|
|
|
gulp.parallel(copy_images, copy_logs, render_js, render_css, compile_page)();
|