readability and stability changes
This commit is contained in:
parent
42ab604d6d
commit
c206314f1c
@ -1,6 +1,5 @@
|
|||||||
const path = require("path");
|
const path = require("path");
|
||||||
const fs = require("fs");
|
const fs = require("fs");
|
||||||
const manifest = require("./data/manifest.json");
|
|
||||||
|
|
||||||
const Nunjucks = require("nunjucks");
|
const Nunjucks = require("nunjucks");
|
||||||
|
|
||||||
|
@ -6,7 +6,21 @@ const TemplateCompiler = require("vue-template-compiler");
|
|||||||
const VueServerRenderer = require("vue-server-renderer");
|
const VueServerRenderer = require("vue-server-renderer");
|
||||||
const requireFromString = require("require-from-string");
|
const requireFromString = require("require-from-string");
|
||||||
const babel = require("@babel/core");
|
const babel = require("@babel/core");
|
||||||
const manifest = require("../data/manifest.json");
|
|
||||||
|
let manifest = {};
|
||||||
|
|
||||||
|
fs.access(
|
||||||
|
path.resolve(__dirname, "..", "data", "manifest.json"),
|
||||||
|
fs.f_OK,
|
||||||
|
err => {
|
||||||
|
if (err) {
|
||||||
|
console.error(err);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
manifest = require("../data/manifest.json");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
module.exports = function(nunjucksEngine, settings) {
|
module.exports = function(nunjucksEngine, settings) {
|
||||||
this.tags = ["vue"];
|
this.tags = ["vue"];
|
||||||
@ -50,7 +64,7 @@ module.exports = function(nunjucksEngine, settings) {
|
|||||||
|
|
||||||
moduleScript.template = parsedComponent.template.content;
|
moduleScript.template = parsedComponent.template.content;
|
||||||
|
|
||||||
if (manifest.vue[args.component]) {
|
if ("vue" in manifest && manifest.vue[args.component]) {
|
||||||
moduleScript._scopeId = `data-v-${manifest.vue[args.component]}`;
|
moduleScript._scopeId = `data-v-${manifest.vue[args.component]}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
86
serve.js
86
serve.js
@ -80,15 +80,19 @@ function startServer() {
|
|||||||
debug(`File changed: ${file}`);
|
debug(`File changed: ${file}`);
|
||||||
build_site(false);
|
build_site(false);
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
match: [
|
||||||
|
path.join(__dirname, "src", "js", "**", "*.js"),
|
||||||
|
path.join(__dirname, "src", "scss", "**", "*"),
|
||||||
|
path.join(__dirname, "src", "svg", "**", "*")
|
||||||
|
],
|
||||||
|
fn: () => build_site(true, false)
|
||||||
|
},
|
||||||
|
{
|
||||||
|
match: [path.join(__dirname, "src", "js", "**", "*.vue")],
|
||||||
|
fn: () => build_site()
|
||||||
}
|
}
|
||||||
// {
|
|
||||||
// match: [
|
|
||||||
// path.join(__dirname, "src", "js", "**", "*"),
|
|
||||||
// path.join(__dirname, "src", "scss", "**", "*"),
|
|
||||||
// path.join(__dirname, "src", "svg", "**", "*")
|
|
||||||
// ],
|
|
||||||
// fn: () => build_site(true, false)
|
|
||||||
// }
|
|
||||||
],
|
],
|
||||||
middleware: [
|
middleware: [
|
||||||
(req, res, next) => {
|
(req, res, next) => {
|
||||||
@ -113,48 +117,42 @@ function startServer() {
|
|||||||
// Run build command
|
// Run build command
|
||||||
const build_site = debounce(
|
const build_site = debounce(
|
||||||
(build_assets = true, build_site = true, file_filter = "") => {
|
(build_assets = true, build_site = true, file_filter = "") => {
|
||||||
co(function*() {
|
if (child && typeof child.pid) {
|
||||||
if (child && typeof child.pid) {
|
info(`Killing ${child.pid}`);
|
||||||
info(`Killing ${child.pid}`);
|
kill_child(child.pid);
|
||||||
yield kill_child(child.pid);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
info("Building Website");
|
info("Building Website");
|
||||||
|
|
||||||
info(`build_assets: ${build_assets}`);
|
info(`build_assets: ${build_assets}`);
|
||||||
info(`file: ${file_filter}`);
|
info(`file: ${file_filter}`);
|
||||||
|
|
||||||
if (build_assets) {
|
if (build_assets) {
|
||||||
// console.log("Webpack Started");
|
// console.log("Webpack Started");
|
||||||
// console.log("Execute webpack build here");
|
// console.log("Execute webpack build here");
|
||||||
// yield run_build_command(
|
run_build_command(`webpack --env ${process.env.NODE_ENV} --watch`).then(
|
||||||
// `webpack --env ${process.env.NODE_ENV} --watch`
|
result => {
|
||||||
// );
|
sync.reload();
|
||||||
// console.log("Webpack Finished");
|
}
|
||||||
// yield run_build_command(`npm run spritesheet`);
|
);
|
||||||
}
|
// console.log("Webpack Finished");
|
||||||
|
// yield run_build_command(`npm run spritesheet`);
|
||||||
|
}
|
||||||
|
|
||||||
if (build_site) {
|
if (build_site) {
|
||||||
info("Build Started");
|
info("Build Started");
|
||||||
const build_command = ["npm run compile"];
|
const build_command = ["npm run compile"];
|
||||||
|
|
||||||
yield run_build_command(build_command.join(" "));
|
run_build_command(build_command.join(" "));
|
||||||
info("Build Finished");
|
info("Build Finished");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!sync.active) {
|
if (!sync.active) {
|
||||||
startServer();
|
startServer();
|
||||||
}
|
}
|
||||||
|
|
||||||
child = void 0;
|
child = void 0;
|
||||||
sync.reload();
|
sync.reload();
|
||||||
}).catch(err => {
|
|
||||||
sync.sockets.emit("fullscreen:message", {
|
|
||||||
title: err.name,
|
|
||||||
body: strip_ansi(`${err.message}\n\n${err.stack}`),
|
|
||||||
timeout: 5e3
|
|
||||||
});
|
|
||||||
});
|
|
||||||
},
|
},
|
||||||
200
|
200
|
||||||
);
|
);
|
||||||
@ -180,4 +178,4 @@ compiler.hooks.afterCompile.tap("eleventy", params => {
|
|||||||
sync.reload();
|
sync.reload();
|
||||||
});
|
});
|
||||||
|
|
||||||
build_site();
|
build_site(false, true);
|
||||||
|
@ -19,10 +19,11 @@ Array.prototype.forEach.call(document.querySelectorAll(".ListComp"), function(
|
|||||||
}).$mount(elem);
|
}).$mount(elem);
|
||||||
});
|
});
|
||||||
|
|
||||||
Array.prototype.forEach.call(document.querySelectorAll(".RecordPlayer"), function(
|
Array.prototype.forEach.call(
|
||||||
elem
|
document.querySelectorAll(".RecordPlayer"),
|
||||||
) {
|
function(elem) {
|
||||||
new Vue({
|
new Vue({
|
||||||
render: h => h(RecordPlayer, { props: { record: elem.dataset.record } })
|
render: h => h(RecordPlayer, { props: { record: elem.dataset.record } })
|
||||||
}).$mount(elem);
|
}).$mount(elem);
|
||||||
});
|
}
|
||||||
|
);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user