@kiln-js/vite-plugin 0.1.1 → 0.1.4
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/dist/index.d.ts +9 -1
- package/dist/index.js +8 -6
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,14 @@
|
|
|
1
1
|
import type { PluginOption } from "vite";
|
|
2
|
-
export interface
|
|
2
|
+
export interface KilnPlugin {
|
|
3
|
+
name: string;
|
|
4
|
+
vite?: () => PluginOption[];
|
|
5
|
+
}
|
|
6
|
+
export interface KilnConfig {
|
|
7
|
+
plugins?: KilnPlugin[];
|
|
8
|
+
}
|
|
9
|
+
export interface KilnOptions extends KilnConfig {
|
|
3
10
|
pagesDir?: string;
|
|
4
11
|
apiDir?: string;
|
|
5
12
|
}
|
|
13
|
+
export declare function defineConfig<T extends KilnConfig>(config: T): T;
|
|
6
14
|
export declare function kiln(opts?: KilnOptions): PluginOption[];
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// src/index.ts
|
|
2
2
|
import path from "node:path";
|
|
3
3
|
import react from "@vitejs/plugin-react";
|
|
4
|
-
import { scanRoutes, scanApi } from "@kiln/core/scan";
|
|
4
|
+
import { scanRoutes, scanApi } from "@kiln-js/core/scan";
|
|
5
5
|
var VIRTUAL = "virtual:kiln-routes";
|
|
6
6
|
var RESOLVED = "\x00" + VIRTUAL;
|
|
7
7
|
var SERVER_FILE = /\.server(\.[jt]sx?)?$/;
|
|
@@ -10,18 +10,18 @@ var PRELUDE = `import __kilnRoutes, { api as __kilnApi } from "${VIRTUAL}";
|
|
|
10
10
|
globalThis.__KILN_ROUTES__ = __kilnRoutes;
|
|
11
11
|
globalThis.__KILN_API__ = __kilnApi;
|
|
12
12
|
`;
|
|
13
|
-
var TITLE_IMPORT = `import { Title as KilnTitle } from "@kiln/core";
|
|
13
|
+
var TITLE_IMPORT = `import { Title as KilnTitle } from "@kiln-js/core";
|
|
14
14
|
`;
|
|
15
15
|
var norm = (p) => p.replace(/\\/g, "/");
|
|
16
|
+
function defineConfig(config) {
|
|
17
|
+
return config;
|
|
18
|
+
}
|
|
16
19
|
function routesPlugin(pagesDir, apiDir) {
|
|
17
20
|
const pagesPrefix = norm(pagesDir) + "/";
|
|
18
21
|
const apiPrefix = norm(apiDir) + "/";
|
|
19
22
|
return {
|
|
20
23
|
name: "kiln:routes",
|
|
21
24
|
enforce: "pre",
|
|
22
|
-
config() {
|
|
23
|
-
return { envPrefix: ["VITE_", "KILN_PUBLIC_"] };
|
|
24
|
-
},
|
|
25
25
|
resolveId(source, _importer, options) {
|
|
26
26
|
if (source === VIRTUAL)
|
|
27
27
|
return RESOLVED;
|
|
@@ -80,8 +80,10 @@ export const api = [
|
|
|
80
80
|
function kiln(opts = {}) {
|
|
81
81
|
const pagesDir = path.resolve(opts.pagesDir ?? "app/pages");
|
|
82
82
|
const apiDir = path.resolve(opts.apiDir ?? "app/api");
|
|
83
|
-
|
|
83
|
+
const extra = (opts.plugins ?? []).flatMap((p) => p.vite?.() ?? []);
|
|
84
|
+
return [react(), routesPlugin(pagesDir, apiDir), ...extra];
|
|
84
85
|
}
|
|
85
86
|
export {
|
|
87
|
+
defineConfig,
|
|
86
88
|
kiln
|
|
87
89
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kiln-js/vite-plugin",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.4",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": {
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
"typecheck": "tsc -p tsconfig.json --noEmit"
|
|
17
17
|
},
|
|
18
18
|
"dependencies": {
|
|
19
|
-
"@kiln-js/core": "
|
|
19
|
+
"@kiln-js/core": "^0.1.4",
|
|
20
20
|
"@vitejs/plugin-react": "^4.3.0"
|
|
21
21
|
},
|
|
22
22
|
"peerDependencies": {
|