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');
|
2021-07-07 00:24:20 +03:00
|
|
|
const handlebars = require('gulp-hb');
|
2021-12-09 02:42:09 +03:00
|
|
|
const sass = require('gulp-sass')(require('sass'));
|
2020-04-04 18:43:31 +03:00
|
|
|
const rename = require('gulp-rename');
|
|
|
|
|
2021-07-07 00:24:20 +03:00
|
|
|
//const hb_svg = require('handlebars-helper-svg');
|
2020-04-04 10:36:08 +03:00
|
|
|
|
|
|
|
const BUILDDIR = process.argv[2] || './build/';
|
2021-07-06 18:49:14 +03:00
|
|
|
|
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
|
2021-07-06 18:49:14 +03:00
|
|
|
gulp.src('./images/*.png').pipe(gulp.dest(BUILDDIR));
|
2022-01-13 22:40:35 +03:00
|
|
|
//favicon
|
|
|
|
gulp.src('./images/*.ico').pipe(gulp.dest(BUILDDIR));
|
2021-04-27 14:00:43 +03:00
|
|
|
// Splash images
|
2021-07-06 18:49:14 +03:00
|
|
|
gulp.src('./images/Splash images/*.png').pipe(gulp.dest(BUILDDIR));
|
2022-01-25 02:33:23 +03:00
|
|
|
// Logs gifs
|
2021-07-06 18:49:14 +03:00
|
|
|
gulp.src('./images/Logs/*.gif').pipe(gulp.dest(BUILDDIR));
|
2022-01-25 02:33:23 +03:00
|
|
|
// Logs pngs
|
2021-12-12 20:37:16 +03:00
|
|
|
gulp.src('./images/Logs/*.png').pipe(gulp.dest(BUILDDIR));
|
2022-01-25 02:33:23 +03:00
|
|
|
// Tool tutorials
|
|
|
|
gulp.src('./images/ToolTutorials/*.gif').pipe(gulp.dest(BUILDDIR));
|
2021-04-27 14:00:43 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
function copy_logs() {
|
2021-07-06 18:49:14 +03:00
|
|
|
gulp.src('logs/*.html').pipe(gulp.dest(BUILDDIR));
|
2020-04-04 18:43:31 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
function render_js(){
|
2022-03-04 22:33:42 +03:00
|
|
|
gulp.src('./js/pixel-editor.js')
|
2020-04-04 18:43:31 +03:00
|
|
|
.pipe(include({includePaths: [
|
|
|
|
'js',
|
|
|
|
'!js/_*.js',
|
|
|
|
]}))
|
|
|
|
.on('error', console.log)
|
2021-07-06 18:49:14 +03:00
|
|
|
.pipe(gulp.dest(BUILDDIR));
|
2020-04-04 18:43:31 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function render_css(){
|
|
|
|
gulp.src('css/*.scss')
|
2021-07-07 00:24:20 +03:00
|
|
|
.pipe(sass({includePaths: ['css']}))
|
2021-07-06 18:49:14 +03:00
|
|
|
.pipe(gulp.dest(BUILDDIR));
|
2020-04-04 18:43:31 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
function compile_page(){
|
2021-07-06 19:00:54 +03:00
|
|
|
gulp.src(path.join('./views/index.hbs'))
|
2021-07-07 00:24:20 +03:00
|
|
|
.pipe(include({includePaths: ['/svg']}))
|
|
|
|
|
|
|
|
.pipe(handlebars({encoding: 'utf8', debug: true, bustCache: true})
|
2021-07-15 19:43:59 +03:00
|
|
|
.partials('./views/[!index]*.hbs').partials('./views/popups/*.hbs')
|
2022-01-31 02:16:27 +03:00
|
|
|
.partials('./views/components/*.hbs')
|
2021-07-07 00:24:20 +03:00
|
|
|
.helpers('./helpers/**/*.js')
|
2020-04-04 18:43:31 +03:00
|
|
|
.data({
|
2021-07-06 19:00:54 +03:00
|
|
|
projectSlug: 'pixel-editor',
|
2020-04-04 18:43:31 +03:00
|
|
|
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
|
2021-12-09 02:42:09 +03:00
|
|
|
try {
|
2020-04-04 18:43:31 +03:00
|
|
|
fs.rmdirSync(BUILDDIR, { recursive: true });
|
|
|
|
fs.mkdirSync(BUILDDIR);
|
2021-12-09 02:42:09 +03:00
|
|
|
} catch (err) {console.log('failed to find build folder, but it\'s probably fine')}
|
|
|
|
|
2021-04-27 14:00:43 +03:00
|
|
|
gulp.parallel(copy_images, copy_logs, render_js, render_css, compile_page)();
|