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');
const BUILDDIR = './build';
const SLUG = 'pixel-editor';
console.log(process.env.HOST?true:false)
console.log('Building Procedural Pixel Art Generator');
console.log('Building Pixel Editor');
hbs.registerHelper('svg', require('handlebars-helper-svg'));
require('hbs-register-helpers')(hbs,'./_ext/modules/hbs/helpers/**/*.js');
@ -21,16 +20,17 @@ fs.emptyDirSync(BUILDDIR);
//copy images
fs.copySync('./images','./build/procedural-pixel-art-generator');
fs.copySync('./images','./build/'+SLUG);
//render js
gulp.src('./js/*.js')
.pipe(include({includePaths: [
'_ext/scripts',
'js'
'js',
'!js/_*.js',
]}))
.on('error', console.log)
.pipe(gulp.dest("build/procedural-pixel-art-generator"));
.pipe(gulp.dest('build/'+SLUG));
//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']});
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
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({
projectSlug: 'procedural-pixel-art-generator',
title: 'Lospec Procedural Pixel Art Generator',
body: content,
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'],
projectSlug: SLUG,
title: 'Lospec Pixel Editor',
layout: false,
});
//save output
@ -70,19 +63,31 @@ const app = express();
//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
app.use(express.static(path.join(__dirname, 'build')));
//start server
app.listen(3000, () => {
var server = app.listen(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');
// opens the url in the default browser
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",
"gulp": "^4.0.0",
"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",
"opn": "^6.0.0",
"sass": "^1.17.3",