Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions docs/react-server.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,14 @@ export default {
accept: "application/xml",
},
},
{
path: "/schema.json",
filename: "schema.json",
method: "GET",
headers: {
accept: "application/json",
},
},
];
},
};
2 changes: 1 addition & 1 deletion docs/src/pages/(i18n).middleware.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { defaultLanguage, languages } from "../const.mjs";
export default function I18n() {
const { pathname } = useUrl();

if (pathname === "/sitemap.xml") {
if (pathname === "/sitemap.xml" || pathname === "/schema.json") {
return;
}

Expand Down
11 changes: 11 additions & 0 deletions docs/src/pages/GET.{schema.json}.server.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { generateJsonSchema } from "@lazarv/react-server/config/schema";

export default function Schema() {
const schema = generateJsonSchema();

return new Response(JSON.stringify(schema, null, 2), {
headers: {
"Content-Type": "application/json",
},
});
}
33 changes: 33 additions & 0 deletions docs/src/pages/en/(pages)/features/configuration.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,39 @@ You can use the `+*.config.*` file to extend the configuration of `@lazarv/react

The `+*.config.*` file is useful when you want to extend the configuration of the runtime. You can use as many `+*.config.*` files as you want. All the configuration files are merged together in the order they are loaded.

<Link name="typed-configuration">
## Typed configuration
</Link>

For **JavaScript and TypeScript** config files, wrap your config with `defineConfig` to get full IntelliSense — autocompletion, type checking, and inline descriptions with examples for every option:

```mjs filename="react-server.config.mjs"
import { defineConfig } from "@lazarv/react-server/config";

export default defineConfig({
port: 3000,
adapter: "vercel",
});
```

For **JSON** config files, add a `$schema` property to enable validation and autocomplete directly in your editor:

```json filename="react-server.config.json"
{
"$schema": "https://react-server.dev/schema.json",
"port": 3000,
"adapter": "vercel"
}
```

The JSON Schema is also available from the package itself for offline use:

```json filename="react-server.config.json"
{
"$schema": "node_modules/@lazarv/react-server/config/schema.json"
}
```

If you want to only add configuration to use when running the runtime in production mode, then use the `.production.config.*` extension. These configuration files only loaded in production mode.

In a similar way, you can create configuration files with the `.development.config.*` extension to use a different configuration for development mode.
Expand Down
33 changes: 33 additions & 0 deletions docs/src/pages/ja/(pages)/features/configuration.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,39 @@ import Link from "../../../../components/Link.jsx";

`+*.config.*` ファイルはランタイムの設定を拡張したい場合に便利です。`+*.config.*`ファイルはいくつでも使うことができます。すべての設定ファイルは読み込まれた順にマージされます。

<Link name="typed-configuration">
## 型付き設定
</Link>

**JavaScriptおよびTypeScript**の設定ファイルでは、`defineConfig`で設定をラップすることで、すべてのオプションに対する自動補完、型チェック、インラインの説明と例を含む完全なIntelliSenseを利用できます:

```mjs filename="react-server.config.mjs"
import { defineConfig } from "@lazarv/react-server/config";

export default defineConfig({
port: 3000,
adapter: "vercel",
});
```

**JSON**設定ファイルでは、`$schema`プロパティを追加することで、エディタ上で直接バリデーションと自動補完を有効にできます:

```json filename="react-server.config.json"
{
"$schema": "https://react-server.dev/schema.json",
"port": 3000,
"adapter": "vercel"
}
```

JSONスキーマはオフライン利用のためにパッケージ自体からも利用できます:

```json filename="react-server.config.json"
{
"$schema": "node_modules/@lazarv/react-server/config/schema.json"
}
```

プロダクションモードでランタイムを実行するときに使用する設定のみを追加したい場合は、`.production.config.*` 拡張子を使用します。これらの設定ファイルはプロダクションモードでのみ読み込まれます。

同じように、`.development.config.*`という拡張子で設定ファイルを作ると、開発モード用に別の設定を使うことができます。
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"root": "src/app",
"layouts": {
"layout": {
"include": ["**/layout.jsx"]
},
"pages": {
"page": {
"include": ["**/page.jsx"]
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4078,10 +4078,10 @@ export default [
",
"react-server.config.json": "{
"root": "src/app",
"layouts": {
"layout": {
"include": ["**/layout.jsx"]
},
"pages": {
"page": {
"include": ["**/page.jsx"]
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4078,10 +4078,10 @@ export default [
",
"react-server.config.json": "{
"root": "src/app",
"layouts": {
"layout": {
"include": ["**/layout.jsx"]
},
"pages": {
"page": {
"include": ["**/page.jsx"]
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4078,10 +4078,10 @@ export default [
",
"react-server.config.json": "{
"root": "src/app",
"layouts": {
"layout": {
"include": ["**/layout.jsx"]
},
"pages": {
"page": {
"include": ["**/page.jsx"]
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3869,10 +3869,10 @@ export default [
",
"react-server.config.json": "{
"root": "src/app",
"layouts": {
"layout": {
"include": ["**/layout.jsx"]
},
"pages": {
"page": {
"include": ["**/page.jsx"]
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3869,10 +3869,10 @@ export default [
",
"react-server.config.json": "{
"root": "src/app",
"layouts": {
"layout": {
"include": ["**/layout.jsx"]
},
"pages": {
"page": {
"include": ["**/page.jsx"]
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3844,10 +3844,10 @@ export default [
",
"react-server.config.json": "{
"root": "src/app",
"layouts": {
"layout": {
"include": ["**/layout.jsx"]
},
"pages": {
"page": {
"include": ["**/page.jsx"]
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3844,10 +3844,10 @@ export default [
",
"react-server.config.json": "{
"root": "src/app",
"layouts": {
"layout": {
"include": ["**/layout.jsx"]
},
"pages": {
"page": {
"include": ["**/page.jsx"]
}
}
Expand Down
14 changes: 8 additions & 6 deletions packages/react-server/config/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
export type ReactServerConfig = any;
export function loadConfig<T extends Record<string, unknown>>(
initialConfig: T
import type { ReactServerConfig } from "./schema.js";

export type { ReactServerConfig } from "./schema.js";
export { DESCRIPTIONS, generateJsonSchema } from "./schema.js";

export function loadConfig(
initialConfig: ReactServerConfig
): Promise<ReactServerConfig>;
export function defineConfig<T extends Record<string, unknown>>(
config: T
): ReactServerConfig;
export function defineConfig(config: ReactServerConfig): ReactServerConfig;

export function forRoot(config?: ReactServerConfig): ReactServerConfig;
export function forChild(config?: ReactServerConfig): ReactServerConfig;
2 changes: 2 additions & 0 deletions packages/react-server/config/index.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -195,3 +195,5 @@ export async function loadConfig(initialConfig, options = {}) {
export function defineConfig(config) {
return config;
}

export { DESCRIPTIONS, generateJsonSchema } from "./schema.mjs";
Loading