Created entry file switch
Added checks for index.njk and data.json files to switch from demo file usage. To prevent override of default files. Updated explanation on demo entry page.
This commit is contained in:
parent
cd870b1bfe
commit
ef9236f47a
3 changed files with 47 additions and 12 deletions
17
gulpfile.js
17
gulpfile.js
|
|
@ -2,9 +2,10 @@
|
|||
const hippie = {
|
||||
brand: 'hippie',
|
||||
jsFile: 'main',
|
||||
jsonFile: 'db'
|
||||
jsonFile: 'db',
|
||||
index: 'demo.html',
|
||||
data: 'demo/data.json'
|
||||
}
|
||||
|
||||
// Gulp requirements
|
||||
const { watch, series, parallel } = require('gulp');
|
||||
const { src, dest } = require('gulp');
|
||||
|
|
@ -68,6 +69,14 @@ const output = {
|
|||
vendor: 'build/vendor'
|
||||
};
|
||||
|
||||
//Check for index file and deactivate demo content
|
||||
if (fs.existsSync('source/screens/index.*')){
|
||||
hippie.index = 'index.html';
|
||||
}
|
||||
if (fs.existsSync('source/templates/data.json')){
|
||||
hippie.data = 'data.json';
|
||||
}
|
||||
|
||||
// Create tasks
|
||||
|
||||
// Clean build folder
|
||||
|
|
@ -99,7 +108,7 @@ function nunjucks() {
|
|||
return src(input.screens)
|
||||
.pipe(plumber())
|
||||
.pipe(data(function() {
|
||||
let data = JSON.parse(fs.readFileSync(input.demo.data));
|
||||
let data = JSON.parse(fs.readFileSync(input.templates +'/'+ hippie.data));
|
||||
object = {hippie, data};
|
||||
return object;
|
||||
}))
|
||||
|
|
@ -115,7 +124,7 @@ function nunjucks() {
|
|||
// Serve files to the browser
|
||||
function serve(done) {
|
||||
server.init({
|
||||
index: "demo.html",
|
||||
index: hippie.index,
|
||||
open: false,
|
||||
server: output.root
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue