@torpor/build 0.0.1 → 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +15 -0
- package/README.md +5 -2
- package/dist/bin/index.cjs +16 -15
- package/dist/bin/index.cjs.map +1 -1
- package/dist/bin/index.js +6 -93
- package/dist/bin/index.js.map +1 -1
- package/dist/chunk-L7GOYKUG.js +93 -0
- package/dist/chunk-L7GOYKUG.js.map +1 -0
- package/dist/index.cjs +103 -9
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +20 -17
- package/dist/index.d.ts +20 -17
- package/dist/index.js +4 -5
- package/dist/index.js.map +1 -1
- package/dist/metafile-cjs.json +1 -1
- package/dist/metafile-esm.json +1 -1
- package/dist/response.cjs.map +1 -1
- package/dist/response.d.cts +4 -0
- package/dist/response.d.ts +4 -0
- package/dist/response.js.map +1 -1
- package/package.json +10 -7
- package/src/bin/index.ts +4 -3
- package/src/index.ts +7 -7
- package/src/response/serverError.ts +2 -0
- package/src/response/unauthorized.ts +2 -0
- package/src/site/FileSystemRouter.ts +1 -0
- package/src/site/clientEntry.ts +3 -3
- package/src/site/defineConfig.ts +73 -3
- package/src/site/routeHandlers.ts +8 -6
- package/src/site/serverEntry.ts +10 -10
- package/src/types/CookieHelper.ts +3 -3
- package/src/types/PageEndPoint.ts +4 -4
- package/src/types/PageEvent.ts +2 -2
- package/src/types/PageServerEndPoint.ts +3 -3
- package/src/types/RouteHandler.ts +3 -3
- package/src/types/RouteHandlerCollection.ts +4 -4
- package/src/types/RouteLayoutHandler.ts +2 -2
- package/src/types/RouteMatchResult.ts +3 -3
- package/src/types/ServerEndPoint.ts +3 -3
- package/src/types/ServerEvent.ts +3 -3
- package/src/types/ServerHook.ts +3 -3
- package/src/types/UserConfig.ts +2 -2
- package/src/vite-env.d.ts +2 -0
- package/tsconfig.json +7 -2
- package/src/site/defineSite.ts +0 -74
package/src/index.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import buildRoutePath from "./site/buildRoutePath";
|
|
2
2
|
import defineConfig from "./site/defineConfig";
|
|
3
|
-
import type PageEndPoint from "./types/PageEndPoint";
|
|
4
|
-
import type PageEvent from "./types/PageEvent";
|
|
5
|
-
import type PageServerEndPoint from "./types/PageServerEndPoint";
|
|
6
|
-
import type ServerEndPoint from "./types/ServerEndPoint";
|
|
7
|
-
import type ServerEvent from "./types/ServerEvent";
|
|
8
|
-
import type ServerHook from "./types/ServerHook";
|
|
9
|
-
import type UserConfig from "./types/UserConfig";
|
|
3
|
+
import { type PageEndPoint } from "./types/PageEndPoint";
|
|
4
|
+
import { type PageEvent } from "./types/PageEvent";
|
|
5
|
+
import { type PageServerEndPoint } from "./types/PageServerEndPoint";
|
|
6
|
+
import { type ServerEndPoint } from "./types/ServerEndPoint";
|
|
7
|
+
import { type ServerEvent } from "./types/ServerEvent";
|
|
8
|
+
import { type ServerHook } from "./types/ServerHook";
|
|
9
|
+
import { type UserConfig } from "./types/UserConfig";
|
|
10
10
|
|
|
11
11
|
// NOTE: Do not export anything that relies on vinxi/vite from here, or it will
|
|
12
12
|
// cause problems when they are re-imported when routes are lazily loaded
|
|
@@ -4,6 +4,7 @@ export default class FileSystemRouter extends BaseFileSystemRouter {
|
|
|
4
4
|
toPath(src: string) {
|
|
5
5
|
let routePath = cleanPath(src, this.config)
|
|
6
6
|
.replace(/^\//, "")
|
|
7
|
+
.replace(/_hook.server$/, "_hook/~server")
|
|
7
8
|
.replace(/_layout.server$/, "_layout/~server")
|
|
8
9
|
.replace(/\+page.server$/, "~server")
|
|
9
10
|
.replace(/\+page$/, "")
|
package/src/site/clientEntry.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { hydrate, mount } from "@torpor/view";
|
|
2
|
-
import type
|
|
2
|
+
import { type Component, type SlotRender } from "@torpor/view";
|
|
3
3
|
import "vinxi/client";
|
|
4
4
|
import $page from "../state/$page";
|
|
5
|
-
import type PageEndPoint from "../types/PageEndPoint";
|
|
6
|
-
import type PageServerEndPoint from "../types/PageServerEndPoint";
|
|
5
|
+
import { type PageEndPoint } from "../types/PageEndPoint";
|
|
6
|
+
import { type PageServerEndPoint } from "../types/PageServerEndPoint";
|
|
7
7
|
import routeHandlers from "./routeHandlers";
|
|
8
8
|
|
|
9
9
|
// Intercept clicks on links
|
package/src/site/defineConfig.ts
CHANGED
|
@@ -1,5 +1,75 @@
|
|
|
1
|
-
import
|
|
1
|
+
import torpor from "@torpor/unplugin/vite";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
import { type AppOptions, type RouterSchemaInput, createApp } from "vinxi";
|
|
4
|
+
import { config } from "vinxi/plugins/config";
|
|
5
|
+
import { type UserConfig } from "../types/UserConfig";
|
|
6
|
+
import FileSystemRouter from "./FileSystemRouter";
|
|
2
7
|
|
|
3
|
-
export default function defineConfig(
|
|
4
|
-
|
|
8
|
+
export default function defineConfig(options?: UserConfig) {
|
|
9
|
+
// Set the port
|
|
10
|
+
process.env.PORT = (options?.port || 7059).toString();
|
|
11
|
+
|
|
12
|
+
// Get Vinxi to create and serve the app
|
|
13
|
+
return createApp({
|
|
14
|
+
name: "torpor",
|
|
15
|
+
routers: [
|
|
16
|
+
{
|
|
17
|
+
name: "assets",
|
|
18
|
+
type: "static",
|
|
19
|
+
dir: "./src/assets",
|
|
20
|
+
},
|
|
21
|
+
// Doesn't look like we can have two server routes?
|
|
22
|
+
// Have to put api in /routes
|
|
23
|
+
// Maybe we can support having /routes/api and routes/site and stripping /site from the start?
|
|
24
|
+
//{
|
|
25
|
+
// name: "api",
|
|
26
|
+
// type: "http",
|
|
27
|
+
// target: "server",
|
|
28
|
+
// // TODO: change this when published
|
|
29
|
+
// handler: "node_modules/@torpor/build/src/site/serverEntry.ts",
|
|
30
|
+
// routes: apiRoutes,
|
|
31
|
+
// plugins: () => [config("custom", viteOptions())],
|
|
32
|
+
//},
|
|
33
|
+
{
|
|
34
|
+
name: "server",
|
|
35
|
+
type: "http",
|
|
36
|
+
target: "server",
|
|
37
|
+
// TODO: change this when published
|
|
38
|
+
handler: "./node_modules/@torpor/build/src/site/serverEntry.ts",
|
|
39
|
+
routes,
|
|
40
|
+
plugins: () => [config("custom", viteOptions()), torpor({ server: true })],
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
name: "client",
|
|
44
|
+
type: "client",
|
|
45
|
+
target: "browser",
|
|
46
|
+
// TODO: change this when published
|
|
47
|
+
handler: "./node_modules/@torpor/build/src/site/clientEntry.ts",
|
|
48
|
+
base: "/_build",
|
|
49
|
+
routes,
|
|
50
|
+
plugins: () => [config("custom", viteOptions()), torpor()],
|
|
51
|
+
},
|
|
52
|
+
],
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
function routes(router: RouterSchemaInput, app: AppOptions) {
|
|
57
|
+
return new FileSystemRouter(
|
|
58
|
+
{
|
|
59
|
+
dir: path.resolve("src/routes"),
|
|
60
|
+
extensions: ["js", "ts"],
|
|
61
|
+
},
|
|
62
|
+
router,
|
|
63
|
+
app,
|
|
64
|
+
);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
function viteOptions() {
|
|
68
|
+
return {
|
|
69
|
+
resolve: {
|
|
70
|
+
alias: {
|
|
71
|
+
"@": path.resolve("src"),
|
|
72
|
+
},
|
|
73
|
+
},
|
|
74
|
+
};
|
|
5
75
|
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { getManifest } from "vinxi/manifest";
|
|
2
|
-
import fileRoutes, { RouteModule } from "vinxi/routes";
|
|
3
|
-
import type RouteHandler from "../types/RouteHandler";
|
|
4
|
-
import type RouteHandlerCollection from "../types/RouteHandlerCollection";
|
|
5
|
-
import type RouteLayoutHandler from "../types/RouteLayoutHandler";
|
|
2
|
+
import fileRoutes, { type RouteModule } from "vinxi/routes";
|
|
3
|
+
import { type RouteHandler } from "../types/RouteHandler";
|
|
4
|
+
import { type RouteHandlerCollection } from "../types/RouteHandlerCollection";
|
|
5
|
+
import { type RouteLayoutHandler } from "../types/RouteLayoutHandler";
|
|
6
6
|
import lazyRoute from "./lazyRoute";
|
|
7
7
|
|
|
8
8
|
const clientManifest = getManifest("client");
|
|
@@ -16,11 +16,13 @@ const routeHandlers: RouteHandlerCollection = {
|
|
|
16
16
|
return {
|
|
17
17
|
...route,
|
|
18
18
|
regex: pathToRegExp(route.path),
|
|
19
|
+
order: /\[([^\/]+?)\]/.test(route.path) ? 1 : 0,
|
|
19
20
|
// TODO: Implement the rest of the lazyRoute stuff from vinxi/react or vinxi/solid
|
|
20
21
|
endPoint: lazyRoute(route.$handler, clientManifest, serverManifest),
|
|
21
22
|
loaded: false,
|
|
22
23
|
};
|
|
23
|
-
})
|
|
24
|
+
})
|
|
25
|
+
.sort((a, b) => a.order - b.order),
|
|
24
26
|
match(path, urlParams) {
|
|
25
27
|
console.log("matching", path);
|
|
26
28
|
|
|
@@ -102,7 +104,7 @@ function findServer(path: string, fileRoutes: RouteModule[]): Promise<any> | und
|
|
|
102
104
|
|
|
103
105
|
function findServerHook(path: string, fileRoutes: RouteModule[]): Promise<any> | undefined {
|
|
104
106
|
// TODO: Should this be a collection, like layouts?
|
|
105
|
-
let hookPath = "/_hook
|
|
107
|
+
let hookPath = "/_hook/~server";
|
|
106
108
|
if (path.startsWith("/api/")) {
|
|
107
109
|
hookPath = "/api" + hookPath;
|
|
108
110
|
}
|
package/src/site/serverEntry.ts
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
import type
|
|
2
|
-
import fs from "fs";
|
|
1
|
+
import { type ServerComponent, type ServerSlotRender } from "@torpor/view";
|
|
2
|
+
import fs from "node:fs";
|
|
3
3
|
import { IncomingMessage } from "node:http";
|
|
4
|
-
import path from "path";
|
|
4
|
+
import path from "node:path";
|
|
5
5
|
import { deleteCookie, eventHandler, getCookie, setCookie } from "vinxi/http";
|
|
6
|
-
import type
|
|
6
|
+
import { type CookieSerializeOptions, type EventHandlerRequest, H3Event } from "vinxi/http";
|
|
7
7
|
import { getManifest } from "vinxi/manifest";
|
|
8
|
-
import { ServerEndPoint } from "..";
|
|
9
8
|
import notFound from "../response/notFound";
|
|
10
9
|
import ok from "../response/ok";
|
|
11
10
|
import seeOther from "../response/seeOther";
|
|
12
11
|
import serverError from "../response/serverError";
|
|
13
12
|
import $page from "../state/$page";
|
|
14
|
-
import type PageEndPoint from "../types/PageEndPoint";
|
|
15
|
-
import type PageServerEndPoint from "../types/PageServerEndPoint";
|
|
16
|
-
import type RouteHandler from "../types/RouteHandler";
|
|
17
|
-
import type
|
|
18
|
-
import type
|
|
13
|
+
import { type PageEndPoint } from "../types/PageEndPoint";
|
|
14
|
+
import { type PageServerEndPoint } from "../types/PageServerEndPoint";
|
|
15
|
+
import { type RouteHandler } from "../types/RouteHandler";
|
|
16
|
+
import { type ServerEndPoint } from "../types/ServerEndPoint";
|
|
17
|
+
import { type ServerEvent } from "../types/ServerEvent";
|
|
18
|
+
import { type ServerHook } from "../types/ServerHook";
|
|
19
19
|
import routeHandlers from "./routeHandlers";
|
|
20
20
|
|
|
21
21
|
let printedRoutes = false;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { CookieSerializeOptions } from "vinxi/http";
|
|
1
|
+
import { type CookieSerializeOptions } from "vinxi/http";
|
|
2
2
|
|
|
3
|
-
export
|
|
3
|
+
export type CookieHelper = {
|
|
4
4
|
get: (name: string) => string | undefined;
|
|
5
5
|
set: (name: string, value: string, options?: CookieSerializeOptions) => void;
|
|
6
6
|
delete: (name: string, options?: CookieSerializeOptions) => void;
|
|
7
|
-
}
|
|
7
|
+
};
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import type
|
|
2
|
-
import type PageEvent from "./PageEvent";
|
|
1
|
+
import { type Component } from "@torpor/view";
|
|
2
|
+
import { type PageEvent } from "./PageEvent";
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* For +page.
|
|
6
6
|
*/
|
|
7
|
-
export
|
|
7
|
+
export type PageEndPoint = {
|
|
8
8
|
/**
|
|
9
9
|
* Builds the route path for the page in a type-safe manner.
|
|
10
10
|
* TODO: Not sure this is actually the best way to do it...
|
|
@@ -23,7 +23,7 @@ export default interface PageEndPoint {
|
|
|
23
23
|
* The head element data for the page, which may include a <title> and <meta> elements.
|
|
24
24
|
*/
|
|
25
25
|
head?: HeadElement[] | ((event: PageEvent) => HeadElement[]);
|
|
26
|
-
}
|
|
26
|
+
};
|
|
27
27
|
|
|
28
28
|
type HeadElement = TitleElement | MetaElement;
|
|
29
29
|
|
package/src/types/PageEvent.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export
|
|
1
|
+
export type PageEvent = {
|
|
2
2
|
/**
|
|
3
3
|
* The URL for the server function.
|
|
4
4
|
*/
|
|
@@ -11,4 +11,4 @@ export default interface PageEvent {
|
|
|
11
11
|
* Data that is (optionally) loaded from the load function and passed into the page as $props.data.
|
|
12
12
|
*/
|
|
13
13
|
data: Record<string, any>;
|
|
14
|
-
}
|
|
14
|
+
};
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import ServerEvent from "./ServerEvent";
|
|
1
|
+
import { type ServerEvent } from "./ServerEvent";
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* For +page.server.
|
|
5
5
|
*/
|
|
6
|
-
export
|
|
6
|
+
export type PageServerEndPoint = {
|
|
7
7
|
/**
|
|
8
8
|
* Loads data from the server for a page.
|
|
9
9
|
*/
|
|
@@ -12,7 +12,7 @@ export default interface PageServerEndPoint {
|
|
|
12
12
|
* A map of actions that can be performed on the server for a page, generally from a form submit.
|
|
13
13
|
*/
|
|
14
14
|
actions?: Record<string, ServerAction>;
|
|
15
|
-
}
|
|
15
|
+
};
|
|
16
16
|
|
|
17
17
|
type ServerLoad = (event: ServerEvent) => Response | Promise<Response | undefined> | void;
|
|
18
18
|
type ServerAction = (event: ServerEvent) => Response | Promise<Response | undefined> | void;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import RouteLayoutHandler from "./RouteLayoutHandler";
|
|
1
|
+
import { type RouteLayoutHandler } from "./RouteLayoutHandler";
|
|
2
2
|
|
|
3
|
-
export
|
|
3
|
+
export type RouteHandler = {
|
|
4
4
|
path: string;
|
|
5
5
|
regex: RegExp;
|
|
6
6
|
endPoint: Promise<any>;
|
|
@@ -9,4 +9,4 @@ export default interface RouteHandler {
|
|
|
9
9
|
layouts?: RouteLayoutHandler[];
|
|
10
10
|
serverEndPoint?: Promise<any>;
|
|
11
11
|
serverHook?: Promise<any>;
|
|
12
|
-
}
|
|
12
|
+
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import type RouteHandler from "./RouteHandler";
|
|
2
|
-
import type RouteMatchResult from "./RouteMatchResult";
|
|
1
|
+
import { type RouteHandler } from "./RouteHandler";
|
|
2
|
+
import { type RouteMatchResult } from "./RouteMatchResult";
|
|
3
3
|
|
|
4
|
-
export
|
|
4
|
+
export type RouteHandlerCollection = {
|
|
5
5
|
handlers: RouteHandler[];
|
|
6
6
|
match(path: string, urlParams?: URLSearchParams): RouteMatchResult | undefined;
|
|
7
|
-
}
|
|
7
|
+
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import type RouteHandler from "./RouteHandler";
|
|
1
|
+
import { type RouteHandler } from "./RouteHandler";
|
|
2
2
|
|
|
3
|
-
export
|
|
3
|
+
export type RouteMatchResult = {
|
|
4
4
|
handler: RouteHandler;
|
|
5
5
|
routeParams?: Record<string, string>;
|
|
6
6
|
urlParams?: Record<string, string>;
|
|
7
|
-
}
|
|
7
|
+
};
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import ServerEvent from "./ServerEvent";
|
|
1
|
+
import { type ServerEvent } from "./ServerEvent";
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* For +server.
|
|
5
5
|
*/
|
|
6
|
-
export
|
|
6
|
+
export type ServerEndPoint = { [key: string]: ServerRequest } & {
|
|
7
7
|
/**
|
|
8
8
|
* Performs a GET.
|
|
9
9
|
*/
|
|
@@ -32,6 +32,6 @@ export default interface ServerEndPoint {
|
|
|
32
32
|
* Perfroms a HEAD request.
|
|
33
33
|
*/
|
|
34
34
|
head?: ServerRequest;
|
|
35
|
-
}
|
|
35
|
+
};
|
|
36
36
|
|
|
37
37
|
type ServerRequest = (event: ServerEvent) => Response | Promise<Response | undefined> | void;
|
package/src/types/ServerEvent.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ServerResponse } from "node:http";
|
|
2
|
-
import CookieHelper from "./CookieHelper";
|
|
2
|
+
import { type CookieHelper } from "./CookieHelper";
|
|
3
3
|
|
|
4
|
-
export
|
|
4
|
+
export type ServerEvent = {
|
|
5
5
|
/**
|
|
6
6
|
* The URL for the server function.
|
|
7
7
|
*/
|
|
@@ -24,4 +24,4 @@ export default interface ServerEvent {
|
|
|
24
24
|
* A helper for getting and setting cookie data.
|
|
25
25
|
*/
|
|
26
26
|
cookies: CookieHelper;
|
|
27
|
-
}
|
|
27
|
+
};
|
package/src/types/ServerHook.ts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import ServerEvent from "./ServerEvent";
|
|
1
|
+
import { type ServerEvent } from "./ServerEvent";
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* For _hook.server.
|
|
5
5
|
*/
|
|
6
|
-
export
|
|
6
|
+
export type ServerHook = {
|
|
7
7
|
/**
|
|
8
8
|
* Called on each server request.
|
|
9
9
|
*/
|
|
10
10
|
handle?: ServerLoad;
|
|
11
|
-
}
|
|
11
|
+
};
|
|
12
12
|
|
|
13
13
|
type ServerLoad = (event: ServerEvent) => Promise<void> | void;
|
package/src/types/UserConfig.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export
|
|
1
|
+
export type UserConfig = {
|
|
2
2
|
port?: number;
|
|
3
|
-
}
|
|
3
|
+
};
|
package/tsconfig.json
CHANGED
|
@@ -1,4 +1,9 @@
|
|
|
1
1
|
{
|
|
2
|
-
"extends": "
|
|
3
|
-
"
|
|
2
|
+
"extends": "../../tsconfig.json",
|
|
3
|
+
"compilerOptions": {
|
|
4
|
+
// TODO: We should be using the tsconfig from the site
|
|
5
|
+
"skipLibCheck": true,
|
|
6
|
+
"verbatimModuleSyntax": false
|
|
7
|
+
},
|
|
8
|
+
"include": ["src"]
|
|
4
9
|
}
|
package/src/site/defineSite.ts
DELETED
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
import torpor from "@torpor/unplugin/vite";
|
|
2
|
-
import path from "path";
|
|
3
|
-
import { AppOptions, RouterSchemaInput, createApp } from "vinxi";
|
|
4
|
-
import { config } from "vinxi/plugins/config";
|
|
5
|
-
import type UserConfig from "../types/UserConfig";
|
|
6
|
-
import FileSystemRouter from "./FileSystemRouter";
|
|
7
|
-
|
|
8
|
-
export default function defineSite(options?: UserConfig) {
|
|
9
|
-
// Set the port
|
|
10
|
-
process.env.PORT = (options?.port || 7059).toString();
|
|
11
|
-
|
|
12
|
-
// Get Vinxi to create and serve the app
|
|
13
|
-
return createApp({
|
|
14
|
-
routers: [
|
|
15
|
-
{
|
|
16
|
-
name: "assets",
|
|
17
|
-
type: "static",
|
|
18
|
-
dir: "./src/assets",
|
|
19
|
-
},
|
|
20
|
-
// Doesn't look like we can have two server routes?
|
|
21
|
-
// Have to put api in /routes
|
|
22
|
-
// Maybe we can support having /routes/api and routes/site and stripping /site from the start?
|
|
23
|
-
//{
|
|
24
|
-
// name: "api",
|
|
25
|
-
// type: "http",
|
|
26
|
-
// target: "server",
|
|
27
|
-
// // TODO: change this when published
|
|
28
|
-
// handler: "node_modules/@torpor/build/src/site/serverEntry.ts",
|
|
29
|
-
// routes: apiRoutes,
|
|
30
|
-
// plugins: () => [config("custom", viteOptions())],
|
|
31
|
-
//},
|
|
32
|
-
{
|
|
33
|
-
name: "server",
|
|
34
|
-
type: "http",
|
|
35
|
-
target: "server",
|
|
36
|
-
// TODO: change this when published
|
|
37
|
-
handler: "node_modules/@torpor/build/src/site/serverEntry.ts",
|
|
38
|
-
routes,
|
|
39
|
-
plugins: () => [config("custom", viteOptions()), torpor({ server: true })],
|
|
40
|
-
},
|
|
41
|
-
{
|
|
42
|
-
name: "client",
|
|
43
|
-
type: "client",
|
|
44
|
-
target: "browser",
|
|
45
|
-
// TODO: change this when published
|
|
46
|
-
handler: "node_modules/@torpor/build/src/site/clientEntry.ts",
|
|
47
|
-
base: "/_build",
|
|
48
|
-
routes,
|
|
49
|
-
plugins: () => [config("custom", viteOptions()), torpor()],
|
|
50
|
-
},
|
|
51
|
-
],
|
|
52
|
-
});
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
function routes(router: RouterSchemaInput, app: AppOptions) {
|
|
56
|
-
return new FileSystemRouter(
|
|
57
|
-
{
|
|
58
|
-
dir: path.resolve("src/routes"),
|
|
59
|
-
extensions: ["js", "ts"],
|
|
60
|
-
},
|
|
61
|
-
router,
|
|
62
|
-
app,
|
|
63
|
-
);
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
function viteOptions() {
|
|
67
|
-
return {
|
|
68
|
-
resolve: {
|
|
69
|
-
alias: {
|
|
70
|
-
"@": path.resolve("src"),
|
|
71
|
-
},
|
|
72
|
-
},
|
|
73
|
-
};
|
|
74
|
-
}
|