@pracht/vite-plugin 0.1.3 → 0.2.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 +6 -3
- package/dist/index.d.mts +12 -0
- package/dist/index.mjs +7 -8
- package/package.json +5 -15
package/README.md
CHANGED
|
@@ -29,6 +29,9 @@ export default defineConfig({
|
|
|
29
29
|
|
|
30
30
|
## Peer Dependencies
|
|
31
31
|
|
|
32
|
-
- `vite@^8.0.0`
|
|
33
|
-
|
|
34
|
-
-
|
|
32
|
+
- `vite@^7.0.0 || ^8.0.0`
|
|
33
|
+
|
|
34
|
+
Target-specific Vite plugins (e.g. `@cloudflare/vite-plugin`) are pulled in by
|
|
35
|
+
the adapter package you install (`@pracht/adapter-cloudflare`,
|
|
36
|
+
`@pracht/adapter-vercel`, etc.). The default path uses `@pracht/adapter-node`,
|
|
37
|
+
which ships as a dependency of this package.
|
package/dist/index.d.mts
CHANGED
|
@@ -23,6 +23,18 @@ interface PrachtAdapter {
|
|
|
23
23
|
* request handler or default export.
|
|
24
24
|
*/
|
|
25
25
|
createServerEntryModule(): string;
|
|
26
|
+
/**
|
|
27
|
+
* Additional Vite plugins the adapter needs (e.g. `@cloudflare/vite-plugin`).
|
|
28
|
+
* Returned plugins are appended to the plugin array returned by `pracht()`.
|
|
29
|
+
*/
|
|
30
|
+
vitePlugins?(): Plugin[] | Promise<Plugin[]>;
|
|
31
|
+
/**
|
|
32
|
+
* If true, the adapter owns dev-server request handling and the vite-plugin
|
|
33
|
+
* will not install its own SSR middleware. Used when the adapter contributes
|
|
34
|
+
* a Vite plugin that runs the dev server in a platform-specific runtime
|
|
35
|
+
* (e.g. Cloudflare workerd via `@cloudflare/vite-plugin`).
|
|
36
|
+
*/
|
|
37
|
+
ownsDevServer?: boolean;
|
|
26
38
|
}
|
|
27
39
|
type RenderMode = "spa" | "ssr" | "ssg" | "isg";
|
|
28
40
|
interface PrachtPluginOptions {
|
package/dist/index.mjs
CHANGED
|
@@ -119,7 +119,7 @@ async function pracht(options = {}) {
|
|
|
119
119
|
if (f.startsWith(abs)) server.restart();
|
|
120
120
|
});
|
|
121
121
|
}
|
|
122
|
-
if (resolved.adapter.
|
|
122
|
+
if (resolved.adapter.ownsDevServer) return;
|
|
123
123
|
return () => {
|
|
124
124
|
server.middlewares.use(createDevSSRMiddleware(server, resolved));
|
|
125
125
|
};
|
|
@@ -151,10 +151,8 @@ async function pracht(options = {}) {
|
|
|
151
151
|
}
|
|
152
152
|
};
|
|
153
153
|
const plugins = [...preact(), prachtPlugin];
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
plugins.push(...cloudflare({ config: { main: "virtual:pracht/server" } }));
|
|
157
|
-
}
|
|
154
|
+
const adapterPlugins = await resolved.adapter.vitePlugins?.();
|
|
155
|
+
if (adapterPlugins?.length) plugins.push(...adapterPlugins);
|
|
158
156
|
return plugins;
|
|
159
157
|
}
|
|
160
158
|
function createPrachtClientModuleSource(options = {}, buildOptions = {}) {
|
|
@@ -256,7 +254,8 @@ function generatePagesAppInlineSource(options, root = process.cwd()) {
|
|
|
256
254
|
function createDevSSRMiddleware(server, _pluginOptions) {
|
|
257
255
|
return async (req, res, next) => {
|
|
258
256
|
const url = req.url ?? "/";
|
|
259
|
-
|
|
257
|
+
const pathname = new URL(url, "http://localhost").pathname;
|
|
258
|
+
if (pathname.includes(".") || pathname.startsWith("/node_modules/")) return next();
|
|
260
259
|
try {
|
|
261
260
|
const [framework, serverMod] = await Promise.all([server.ssrLoadModule("@pracht/core"), server.ssrLoadModule(PRACHT_SERVER_MODULE_ID)]);
|
|
262
261
|
let webRequest;
|
|
@@ -356,8 +355,8 @@ function resolveOptions(options) {
|
|
|
356
355
|
};
|
|
357
356
|
}
|
|
358
357
|
function readClientBuildAssets(root = process.cwd()) {
|
|
359
|
-
const manifestPath =
|
|
360
|
-
if (!
|
|
358
|
+
const manifestPath = ["dist/client/.vite/manifest.json", "dist/.vite/manifest.json"].map((candidate) => resolve(root, candidate)).find((candidate) => existsSync(candidate));
|
|
359
|
+
if (!manifestPath) return {
|
|
361
360
|
clientEntryUrl: null,
|
|
362
361
|
cssManifest: {},
|
|
363
362
|
jsManifest: {}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pracht/vite-plugin",
|
|
3
|
-
"version": "0.1
|
|
3
|
+
"version": "0.2.1",
|
|
4
4
|
"homepage": "https://github.com/JoviDeCroock/pracht/tree/main/packages/vite-plugin",
|
|
5
5
|
"bugs": {
|
|
6
6
|
"url": "https://github.com/JoviDeCroock/pracht/issues"
|
|
@@ -29,22 +29,12 @@
|
|
|
29
29
|
},
|
|
30
30
|
"dependencies": {
|
|
31
31
|
"@preact/preset-vite": "^2.10.5",
|
|
32
|
-
"@
|
|
33
|
-
"@pracht/adapter-
|
|
34
|
-
"@pracht/core": "0.2.
|
|
32
|
+
"@prefresh/vite": "^2.0.0",
|
|
33
|
+
"@pracht/adapter-node": "0.1.5",
|
|
34
|
+
"@pracht/core": "0.2.4"
|
|
35
35
|
},
|
|
36
36
|
"peerDependencies": {
|
|
37
|
-
"
|
|
38
|
-
"vite": "^8.0.0",
|
|
39
|
-
"wrangler": "^4.81.0"
|
|
40
|
-
},
|
|
41
|
-
"peerDependenciesMeta": {
|
|
42
|
-
"@cloudflare/vite-plugin": {
|
|
43
|
-
"optional": true
|
|
44
|
-
},
|
|
45
|
-
"wrangler": {
|
|
46
|
-
"optional": true
|
|
47
|
-
}
|
|
37
|
+
"vite": "^7.0.0 || ^8.0.0"
|
|
48
38
|
},
|
|
49
39
|
"scripts": {
|
|
50
40
|
"build": "tsdown"
|