eeg_nest/esbuild.js

63 lines
1.4 KiB
JavaScript
Raw Normal View History

2023-06-13 03:08:21 +00:00
const { context } = require("esbuild");
2023-05-07 00:14:11 +00:00
const { solidPlugin } = require("esbuild-plugin-solid");
const { glob } = require("glob");
2023-05-06 11:57:46 +00:00
2023-06-13 03:08:21 +00:00
const genHydration = (path) => async () => {
2023-05-17 18:04:11 +00:00
const ctx = await context({
platform: "browser",
entryPoints: [
2023-06-13 03:08:21 +00:00
path,
2023-05-17 18:04:11 +00:00
],
bundle: true,
minify: false,
logLevel: "info",
plugins: [
solidPlugin({
2023-05-07 00:06:11 +00:00
solid: {
2023-05-17 18:04:11 +00:00
generate: "dom",
2023-05-07 00:06:11 +00:00
hydratable: true,
},
2023-05-17 18:04:11 +00:00
})
],
outdir: "static",
format: "cjs",
2023-05-07 00:06:11 +00:00
});
2023-05-07 00:14:11 +00:00
2023-05-17 18:04:11 +00:00
await ctx.watch();
console.log("Watching hydration script...");
2023-06-13 03:08:21 +00:00
};
2023-06-12 03:25:18 +00:00
2023-06-13 03:08:21 +00:00
/**
* Compile JSX files
*/
(async() => {
const files = await glob("dist/**/*.jsx");
console.log(files);
2023-06-12 03:25:18 +00:00
const ctx = await context({
2023-06-13 03:08:21 +00:00
platform: "node",
entryPoints: files,
bundle: false,
2023-06-12 03:25:18 +00:00
minify: false,
logLevel: "info",
2023-06-13 03:08:21 +00:00
plugins: [solidPlugin({
solid: {
generate: "ssr",
hydratable: true,
},
})],
outdir: "dist",
outbase: "dist",
2023-06-12 03:25:18 +00:00
format: "cjs",
});
await ctx.watch();
2023-06-13 03:08:21 +00:00
console.log("Watching Solid JSX...");
2023-06-12 03:25:18 +00:00
})();
2023-06-13 03:08:21 +00:00
/**
* Generate hydration script
*/
(genHydration("src/views/hydration.ts"))();
(genHydration("src/views/hydration/hydration_aulavirtual.ts"))();
(genHydration("src/views/hydration/hydration_batch_mode.ts"))();