finish build file

This commit is contained in:
skeddles 2019-03-27 22:19:15 -04:00
parent 3fd10d2d17
commit 548fea2909
3 changed files with 809 additions and 827 deletions

View File

@ -7,10 +7,9 @@ var gulp = require('gulp');
var include = require('gulp-include'); var include = require('gulp-include');
const BUILDDIR = './build'; const BUILDDIR = './build';
const SLUG = 'pixel-editor';
console.log(process.env.HOST?true:false) console.log('Building Pixel Editor');
console.log('Building Procedural Pixel Art Generator');
hbs.registerHelper('svg', require('handlebars-helper-svg')); hbs.registerHelper('svg', require('handlebars-helper-svg'));
require('hbs-register-helpers')(hbs,'./_ext/modules/hbs/helpers/**/*.js'); require('hbs-register-helpers')(hbs,'./_ext/modules/hbs/helpers/**/*.js');
@ -21,16 +20,17 @@ fs.emptyDirSync(BUILDDIR);
//copy images //copy images
fs.copySync('./images','./build/procedural-pixel-art-generator'); fs.copySync('./images','./build/'+SLUG);
//render js //render js
gulp.src('./js/*.js') gulp.src('./js/*.js')
.pipe(include({includePaths: [ .pipe(include({includePaths: [
'_ext/scripts', '_ext/scripts',
'js' 'js',
'!js/_*.js',
]})) ]}))
.on('error', console.log) .on('error', console.log)
.pipe(gulp.dest("build/procedural-pixel-art-generator")); .pipe(gulp.dest('build/'+SLUG));
//render css //render css
@ -41,23 +41,16 @@ sassFiles.forEach((s) => {
var f = sass.renderSync({file: s, outFile: 'test.css', includePaths: ['css', '_ext/sass', '_ext/modules/css']}); var f = sass.renderSync({file: s, outFile: 'test.css', includePaths: ['css', '_ext/sass', '_ext/modules/css']});
console.log('compiling:',path.basename(f.stats.entry)) console.log('compiling:',path.basename(f.stats.entry))
fs.writeFileSync('build/procedural-pixel-art-generator/'+path.basename(f.stats.entry,'scss')+'css', f.css); fs.writeFileSync('build/'+SLUG+'/'+path.basename(f.stats.entry,'scss')+'css', f.css);
}); });
//compile content
var contentTemplate = hbs.compile(fs.readFileSync('./views/procedural-pixel-art-generator.hbs',{encoding: 'utf8'}));
var content = contentTemplate();
//compile page //compile page
var pageTemplate = hbs.compile(fs.readFileSync('./_ext/modules/hbs/layout-contribute.hbs',{encoding: 'utf8'})); var pageTemplate = hbs.compile(fs.readFileSync('./views/'+SLUG+'.hbs',{encoding: 'utf8'}));
var page = pageTemplate({ var page = pageTemplate({
projectSlug: 'procedural-pixel-art-generator', projectSlug: SLUG,
title: 'Lospec Procedural Pixel Art Generator', title: 'Lospec Pixel Editor',
body: content, layout: false,
css: ['https://lospec.com/stylesheets/style.css','procedural-pixel-art-generator/procedural-pixel-art-generator.css'],
js: ['procedural-pixel-art-generator/procedural-pixel-art-generator.js'],
}); });
//save output //save output
@ -70,19 +63,31 @@ const app = express();
//ROUTE - index.htm //ROUTE - index.htm
app.get('/', (req, res) => res.sendFile(path.join(__dirname+'/build/index.htm'))); app.get('/', (req, res) => {
res.sendFile(path.join(__dirname+'/build/index.htm'), {}, function (err) {
if (err) console.log('error sending file',err);
else {
setTimeout(()=>{
console.log('closing server')
server.close();
process.exit();
},1000*10);
}
});
});
//ROUTE - other files //ROUTE - other files
app.use(express.static(path.join(__dirname, 'build'))); app.use(express.static(path.join(__dirname, 'build')));
//start server //start server
app.listen(3000, () => { var server = app.listen(3000, () => {
console.log('\nTemp server started at http://localhost:3000!'); console.log('\nTemp server started at http://localhost:3000!');
console.log('press ctrl+c to stop '); //console.log('press ctrl+c to stop ');
var opn = require('opn'); var opn = require('opn');
// opens the url in the default browser // opens the url in the default browser
opn('http://localhost:3000'); opn('http://localhost:3000');
}); });

1587
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -14,7 +14,7 @@
"glob": "^7.1.3", "glob": "^7.1.3",
"gulp": "^4.0.0", "gulp": "^4.0.0",
"gulp-include": "^2.3.1", "gulp-include": "^2.3.1",
"handlebars-helper-svg": "^2.0.1", "handlebars-helper-svg": "git+https://bitbucket.org/skeddles/npm-handlebars-helper-svg-lospec-open-source.git",
"hbs": "^4.0.3", "hbs": "^4.0.3",
"opn": "^6.0.0", "opn": "^6.0.0",
"sass": "^1.17.3", "sass": "^1.17.3",