Gisle Aune
6 years ago
5 changed files with 104 additions and 20 deletions
-
3Dockerfile
-
53build.js
-
15builder.js
-
2package.json
-
43server.js
@ -0,0 +1,53 @@ |
|||
const build = require("./builder") |
|||
|
|||
// Setup global environment
|
|||
require("marko/node-require").install() |
|||
require("es6-promise").polyfill() |
|||
|
|||
// Configure lasso
|
|||
require("lasso").configure({ |
|||
plugins: [ |
|||
"lasso-marko", |
|||
"lasso-less", |
|||
], |
|||
outputDir: "./.static", |
|||
bundlingEnabled: true, |
|||
minify: true, |
|||
fingerprintsEnabled: true, |
|||
|
|||
require: { |
|||
builtins: { |
|||
fs: require.resolve("empty-module"), |
|||
}, |
|||
|
|||
transforms: [ |
|||
{ |
|||
transform: "lasso-babel-transform", |
|||
config: { |
|||
extensions: [".js", ".es6"], // Enabled file extensions. Default: [".js", ".es6"]
|
|||
babelOptions: { |
|||
presets: [ "es2015" ] |
|||
} |
|||
} |
|||
} |
|||
] |
|||
} |
|||
}) |
|||
|
|||
// Render templates
|
|||
async function buildAll() { |
|||
await build("./marko/page/story/list.marko") |
|||
await build("./marko/page/story/tag-list.marko", {tags: []}) |
|||
await build("./marko/page/logs/list.marko") |
|||
await build("./marko/page/data/channels.marko", {channels: [], user: {}}) |
|||
await build("./marko/page/data/characters.marko", {characters: [], user: {}}) |
|||
await build("./marko/page/story-content/view.marko", {story: {chapters: []}}) |
|||
await build("./marko/page/logs-content/view.marko", {log: {posts: [], channel: {}}}) |
|||
} |
|||
|
|||
buildAll().then(() => { |
|||
console.log("Done!") |
|||
}).catch(err => { |
|||
console.error(err) |
|||
process.exit(1) |
|||
}) |
@ -0,0 +1,15 @@ |
|||
module.exports = function build(path, data) { |
|||
console.log("Building", path) |
|||
|
|||
return new Promise((resolve, reject) => { |
|||
const render = require(path).render(data) |
|||
render.once("error", err => reject) |
|||
|
|||
const interval = setInterval(() => { |
|||
if (render._remaining === 0) { |
|||
clearInterval(interval) |
|||
resolve() |
|||
} |
|||
}, 500) |
|||
}) |
|||
} |
Write
Preview
Loading…
Cancel
Save
Reference in new issue