@pracht/vite-plugin 0.0.0 → 0.0.1
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/README.md +34 -0
- package/dist/index.d.mts +1 -0
- package/dist/index.mjs +13 -3
- package/package.json +16 -4
package/README.md
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
# @pracht/vite-plugin
|
|
2
|
+
|
|
3
|
+
Vite integration for pracht. Handles virtual module generation, multi-environment builds, and SSG prerendering.
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @pracht/vite-plugin
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Usage
|
|
12
|
+
|
|
13
|
+
```ts
|
|
14
|
+
// vite.config.ts
|
|
15
|
+
import { defineConfig } from "vite";
|
|
16
|
+
import pracht from "@pracht/vite-plugin";
|
|
17
|
+
|
|
18
|
+
export default defineConfig({
|
|
19
|
+
plugins: [pracht()],
|
|
20
|
+
});
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
## What It Does
|
|
24
|
+
|
|
25
|
+
- Generates virtual modules (`virtual:pracht/client`, `virtual:pracht/server`) from your route manifest
|
|
26
|
+
- Builds client and SSR bundles via Vite's multi-environment mode
|
|
27
|
+
- Pre-renders SSG and ISG routes at build time
|
|
28
|
+
- Provides HMR during development
|
|
29
|
+
|
|
30
|
+
## Peer Dependencies
|
|
31
|
+
|
|
32
|
+
- `vite@^8.0.0`
|
|
33
|
+
- `@cloudflare/vite-plugin@^1.0.0` (optional, for Cloudflare targets)
|
|
34
|
+
- `wrangler@^4.81.0` (optional, for Cloudflare targets)
|
package/dist/index.d.mts
CHANGED
|
@@ -44,6 +44,7 @@ declare function createPrachtClientModuleSource(options?: PrachtPluginOptions, b
|
|
|
44
44
|
}): string;
|
|
45
45
|
declare function createPrachtServerModuleSource(options?: PrachtPluginOptions, buildOptions?: {
|
|
46
46
|
root?: string;
|
|
47
|
+
isBuild?: boolean;
|
|
47
48
|
}): string;
|
|
48
49
|
declare function createPrachtRegistryModuleSource(options?: PrachtPluginOptions): string;
|
|
49
50
|
//#endregion
|
package/dist/index.mjs
CHANGED
|
@@ -71,6 +71,7 @@ async function pracht(options = {}) {
|
|
|
71
71
|
const isPagesMode = !!resolved.pagesDir;
|
|
72
72
|
let root = process.cwd();
|
|
73
73
|
if (isPagesMode && options.appFile) console.warn("[pracht] Both `pagesDir` and `appFile` are set. `pagesDir` takes precedence — `appFile` will be ignored.");
|
|
74
|
+
let isBuild = false;
|
|
74
75
|
const prachtPlugin = {
|
|
75
76
|
name: "pracht",
|
|
76
77
|
enforce: "pre",
|
|
@@ -84,6 +85,7 @@ async function pracht(options = {}) {
|
|
|
84
85
|
},
|
|
85
86
|
configResolved(config) {
|
|
86
87
|
root = config.root;
|
|
88
|
+
isBuild = config.command === "build";
|
|
87
89
|
},
|
|
88
90
|
resolveId(id) {
|
|
89
91
|
if (isClientModule(id)) return PRACHT_CLIENT_MODULE_ID;
|
|
@@ -92,7 +94,10 @@ async function pracht(options = {}) {
|
|
|
92
94
|
},
|
|
93
95
|
load(id) {
|
|
94
96
|
if (isClientModule(id)) return createPrachtClientModuleSource(resolved, { root });
|
|
95
|
-
if (isServerModule(id)) return createPrachtServerModuleSource(resolved, {
|
|
97
|
+
if (isServerModule(id)) return createPrachtServerModuleSource(resolved, {
|
|
98
|
+
root,
|
|
99
|
+
isBuild
|
|
100
|
+
});
|
|
96
101
|
return null;
|
|
97
102
|
},
|
|
98
103
|
configureServer(server) {
|
|
@@ -186,10 +191,14 @@ function createPrachtServerModuleSource(options = {}, buildOptions = {}) {
|
|
|
186
191
|
const resolved = resolveOptions(options);
|
|
187
192
|
const isPagesMode = !!resolved.pagesDir;
|
|
188
193
|
const registrySource = createPrachtRegistryModuleSource(resolved);
|
|
189
|
-
const clientBuild = readClientBuildAssets(buildOptions.root)
|
|
194
|
+
const clientBuild = buildOptions.isBuild ? readClientBuildAssets(buildOptions.root) : {
|
|
195
|
+
clientEntryUrl: null,
|
|
196
|
+
cssManifest: {},
|
|
197
|
+
jsManifest: {}
|
|
198
|
+
};
|
|
190
199
|
const adapter = resolved.adapter;
|
|
191
200
|
const source = [
|
|
192
|
-
adapter?.serverImports ? adapter.serverImports : "import { resolveApp, resolveApiRoutes } from \"@pracht/core\";",
|
|
201
|
+
adapter?.serverImports ? adapter.serverImports + "\nimport { prerenderApp } from \"@pracht/core\";" : "import { resolveApp, resolveApiRoutes, prerenderApp } from \"@pracht/core\";",
|
|
193
202
|
isPagesMode ? generatePagesAppInlineSource(resolved, buildOptions.root) : `import { app } from ${JSON.stringify(resolved.appFile)};`,
|
|
194
203
|
"",
|
|
195
204
|
registrySource,
|
|
@@ -200,6 +209,7 @@ function createPrachtServerModuleSource(options = {}, buildOptions = {}) {
|
|
|
200
209
|
`export const clientEntryUrl = ${JSON.stringify(clientBuild.clientEntryUrl ?? CLIENT_BROWSER_PATH)};`,
|
|
201
210
|
`export const cssManifest = ${JSON.stringify(clientBuild.cssManifest)};`,
|
|
202
211
|
`export const jsManifest = ${JSON.stringify(clientBuild.jsManifest)};`,
|
|
212
|
+
"export { prerenderApp };",
|
|
203
213
|
""
|
|
204
214
|
];
|
|
205
215
|
if (adapter) source.push(adapter.createServerEntryModule());
|
package/package.json
CHANGED
|
@@ -1,10 +1,22 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pracht/vite-plugin",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"repository": {
|
|
5
|
+
"type": "git",
|
|
6
|
+
"url": "https://github.com/JoviDeCroock/pracht",
|
|
7
|
+
"directory": "packages/vite-plugin"
|
|
8
|
+
},
|
|
9
|
+
"homepage": "https://github.com/JoviDeCroock/pracht/tree/main/packages/vite-plugin",
|
|
10
|
+
"bugs": {
|
|
11
|
+
"url": "https://github.com/JoviDeCroock/pracht/issues"
|
|
12
|
+
},
|
|
4
13
|
"files": [
|
|
5
14
|
"dist"
|
|
6
15
|
],
|
|
7
16
|
"type": "module",
|
|
17
|
+
"publishConfig": {
|
|
18
|
+
"provenance": true
|
|
19
|
+
},
|
|
8
20
|
"exports": {
|
|
9
21
|
".": {
|
|
10
22
|
"types": "./dist/index.d.mts",
|
|
@@ -17,9 +29,9 @@
|
|
|
17
29
|
},
|
|
18
30
|
"dependencies": {
|
|
19
31
|
"@preact/preset-vite": "^2.10.5",
|
|
20
|
-
"@pracht/adapter-cloudflare": "0.0.
|
|
21
|
-
"@pracht/core": "0.0.
|
|
22
|
-
"@pracht/adapter-vercel": "0.0.
|
|
32
|
+
"@pracht/adapter-cloudflare": "0.0.1",
|
|
33
|
+
"@pracht/core": "0.0.1",
|
|
34
|
+
"@pracht/adapter-vercel": "0.0.1"
|
|
23
35
|
},
|
|
24
36
|
"peerDependencies": {
|
|
25
37
|
"@cloudflare/vite-plugin": "^1.0.0",
|