Move to esbuild
parent
b24d6d1a0b
commit
c64a950746
@ -0,0 +1,40 @@
|
|||||||
|
const { build } = require("esbuild");
|
||||||
|
const { sassPlugin } = require("esbuild-sass-plugin");
|
||||||
|
const glob = require("tiny-glob");
|
||||||
|
|
||||||
|
const watch = process.argv.at(-1) === "--watch";
|
||||||
|
|
||||||
|
(async () => {
|
||||||
|
let entryPoints = Object.fromEntries(
|
||||||
|
(await glob("./src/back/**/*.ts")).map((e) => [
|
||||||
|
e.replace(/\.ts$/, ""),
|
||||||
|
e,
|
||||||
|
])
|
||||||
|
);
|
||||||
|
build({
|
||||||
|
entryPoints,
|
||||||
|
sourcemap: true,
|
||||||
|
outdir: "./dist",
|
||||||
|
logLevel: "info",
|
||||||
|
platform: "node",
|
||||||
|
watch,
|
||||||
|
target: "node16",
|
||||||
|
format: "cjs",
|
||||||
|
});
|
||||||
|
build({
|
||||||
|
entryPoints: ["./src/front/main.scss"],
|
||||||
|
sourcemap: true,
|
||||||
|
outfile: "./public/dist/style.css",
|
||||||
|
logLevel: "info",
|
||||||
|
watch,
|
||||||
|
plugins: [sassPlugin()],
|
||||||
|
});
|
||||||
|
build({
|
||||||
|
entryPoints: ["./src/front/index.ts"],
|
||||||
|
sourcemap: true,
|
||||||
|
outfile: "./public/dist/bundle.js",
|
||||||
|
logLevel: "info",
|
||||||
|
bundle: true,
|
||||||
|
watch,
|
||||||
|
});
|
||||||
|
})();
|
File diff suppressed because it is too large
Load Diff
@ -1,25 +1,14 @@
|
|||||||
|
import Router from "@koa/router";
|
||||||
import { Middlewares } from "sealious";
|
import { Middlewares } from "sealious";
|
||||||
import html from "../html";
|
import { loginRouter } from "./login/index.js";
|
||||||
import { NewTask, TaskList } from "../views/tasks";
|
import { MainView } from "./main-view.js";
|
||||||
import { BaseContext } from "koa";
|
import { tasksRouter } from "./tasks/index.js";
|
||||||
import { Readable } from "stream";
|
|
||||||
import { tempstream } from "tempstream";
|
|
||||||
import { router } from "..";
|
|
||||||
|
|
||||||
export function MainView(ctx: BaseContext): Readable {
|
|
||||||
return html(
|
|
||||||
ctx,
|
|
||||||
/* HTML */ tempstream` <title>My ToDo App</title>
|
|
||||||
<body>
|
|
||||||
<h1>My ToDo App</h1>
|
|
||||||
${TaskList(ctx.$context)} ${NewTask()}
|
|
||||||
</body>`
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
export const mainRouter = (router: Router): void => {
|
||||||
router.get("/", Middlewares.extractContext(), async (ctx) => {
|
router.get("/", Middlewares.extractContext(), async (ctx) => {
|
||||||
ctx.body = MainView(ctx);
|
ctx.body = MainView(ctx);
|
||||||
});
|
});
|
||||||
|
|
||||||
require("./login/index");
|
loginRouter(router);
|
||||||
require("./tasks/index");
|
tasksRouter(router);
|
||||||
|
};
|
||||||
|
@ -0,0 +1,17 @@
|
|||||||
|
import html from "../html";
|
||||||
|
import { BaseContext } from "koa";
|
||||||
|
import { Readable } from "stream";
|
||||||
|
import { tempstream } from "tempstream";
|
||||||
|
import { NewTask, TaskList } from "../views/tasks";
|
||||||
|
|
||||||
|
export function MainView(ctx: BaseContext): Readable {
|
||||||
|
return html(
|
||||||
|
ctx,
|
||||||
|
tempstream/* HTML */ ` <title>My Own ToDo App</title>
|
||||||
|
<body>
|
||||||
|
<h1>My ToDo App (with esbuild!)</h1>
|
||||||
|
|
||||||
|
${TaskList(ctx.$context)} ${NewTask()}
|
||||||
|
</body>`
|
||||||
|
);
|
||||||
|
}
|
Loading…
Reference in New Issue