defuss-ssg 0.4.0 → 0.5.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/README.md CHANGED
@@ -1,338 +1,320 @@
1
- <h1 align="center">
1
+ # defuss-ssg
2
2
 
3
- <img src="https://github.com/kyr0/defuss/blob/main/assets/defuss_mascott.png?raw=true" width="100px" />
3
+ Static site generation, request-time dev SSR, file-based endpoints, and production serving for defuss.
4
4
 
5
- <p align="center">
6
-
7
- <code>defuss-ssg</code>
5
+ `defuss-ssg` is both a CLI and a library:
8
6
 
9
- </p>
7
+ - `dev` starts a Vite server and renders MD/MDX pages on demand through SSR.
8
+ - `build` renders static HTML, bundles client components, compiles endpoints, and copies assets.
9
+ - `serve` serves built output with `defuss-express`, plus dynamic endpoints and optional RPC.
10
10
 
11
- <sup align="center">
11
+ Use Bun for package management. The published package targets Node `^20.19.0 || >=22.12.0`.
12
12
 
13
- Static Site Generator (SSG) for defuss
13
+ ## What It Supports
14
14
 
15
- </sup>
15
+ - Markdown and MDX pages from `pages/`
16
+ - YAML or TOML frontmatter exposed as `meta`
17
+ - GitHub Flavored Markdown via `remark-gfm`
18
+ - KaTeX math via `$...$` and `$$...$$`
19
+ - defuss components imported into MDX and HTML-like pages
20
+ - Automatic hydration boundaries for components rendered from `components/`
21
+ - Static assets copied from `assets/`
22
+ - File-based API routes from `pages/**/*.ts` and `pages/**/*.js`
23
+ - Pre-rendered endpoints via `prerender = true` and `getStaticPaths()`
24
+ - RPC auto-discovery from `rpc.ts` or `rpc.js` when `defuss-rpc` is installed
25
+ - Plugin hooks for `pre`, `page-vdom`, `page-dom`, `page-html`, and `post`
26
+ - Multicore production serving through `--multicore` or `workers: "auto"`
16
27
 
17
- </h1>
28
+ ## Install
18
29
 
19
- <h3 align="center">
20
- Usage
21
- </h3>
22
-
23
- Simply generate a static site from a content directory to an output directory with full defuss-MDX (GFM + Frontmatter) support:
30
+ Run directly:
24
31
 
25
32
  ```bash
26
- bunx defuss-ssg build ./folder
33
+ bunx defuss-ssg build ./my-site
27
34
  ```
28
35
 
29
- Or install globally or locally in a project:
36
+ Or add it as a dev dependency:
30
37
 
31
- ```bash
32
- bun add -g defuss-ssg
38
+ ```bash
39
+ bun add -D defuss-ssg
33
40
  ```
34
41
 
35
- And then run (in an NPM script or globally):
42
+ ## Quick Start
36
43
 
37
- <h4>One-time builds</h4>
38
-
39
- ```bash
40
- defuss-ssg build ./folder
44
+ ```text
45
+ my-site/
46
+ ├-- pages/
47
+ | ├-- index.mdx
48
+ | └-- api/
49
+ | └-- ping.json.ts
50
+ ├-- components/
51
+ | └-- button.tsx
52
+ ├-- assets/
53
+ | └-- styles.css
54
+ ├-- config.ts
55
+ └-- rpc.ts
41
56
  ```
42
57
 
43
- <h4>Vite-powered development</h4>
58
+ Minimal config:
59
+
60
+ ```ts
61
+ import { rehypePlugins, remarkPlugins, type SsgConfig } from "defuss-ssg";
62
+
63
+ const config: SsgConfig = {
64
+ pages: "pages",
65
+ output: "dist",
66
+ components: "components",
67
+ assets: "assets",
68
+ tmp: ".ssg-temp",
69
+ plugins: [],
70
+ remarkPlugins: [...remarkPlugins],
71
+ rehypePlugins: [...rehypePlugins],
72
+ rpc: true,
73
+ };
44
74
 
45
- ```bash
46
- defuss-ssg dev ./folder
75
+ export default config;
47
76
  ```
48
77
 
49
- This starts a Vite dev server at http://localhost:3000 and watches for changes in:
78
+ Example page:
50
79
 
51
- - `pages/` directory
52
- - `components/` directory
53
- - `assets/` directory
80
+ ```mdx
81
+ ---
82
+ title: Home
83
+ ---
54
84
 
55
- Changes trigger automatic rebuilds, with the last change always taking priority to prevent build queueing issues.
85
+ import { Button } from "../components/button.js";
56
86
 
57
- The current migration bridge still writes dev output to `dist/` while the request-time Vite renderer is being moved over.
87
+ # {meta.title}
58
88
 
59
- <h4>Production serving</h4>
89
+ This page uses MDX, frontmatter, and a defuss component.
60
90
 
61
- ```bash
62
- defuss-ssg serve ./folder
91
+ <Button label="Click me" />
63
92
  ```
64
93
 
65
- This serves already-built output with `defuss-express`. Run `defuss-ssg build ./folder` first.
94
+ Example component:
66
95
 
67
- <h4>Local development of SSG and running the example</h4>
68
-
69
- Unlike other SSG systems, this package is **not** meant to be installed in a project, but rather used as a global CLI tool or programmatically.
96
+ ```tsx
97
+ export function Button({ label }: { label: string }) {
98
+ return <button type="button">{label}</button>;
99
+ }
100
+ ```
70
101
 
71
- Developing this means to clone the repo, install dependencies and run the example site:
102
+ Build the site:
72
103
 
73
104
  ```bash
74
- git clone https://github.com/kyr0/defuss.git
105
+ defuss-ssg build ./my-site
106
+ ```
75
107
 
76
- cd defuss/packages/ssg
108
+ Start Vite-powered development:
77
109
 
78
- bun i && bun build
110
+ ```bash
111
+ defuss-ssg dev ./my-site
112
+ ```
79
113
 
80
- # for building and serving the example site with auto-rebuild:
81
- bun run cli-dev ./example
114
+ Serve the already built output:
82
115
 
83
- # for one-time build of the example site:
84
- bun run cli-build ./example
116
+ ```bash
117
+ defuss-ssg serve ./my-site
85
118
  ```
86
119
 
87
- Please create a PR or issue if you find any bugs or have feature requests.
120
+ `serve` expects existing build output in `dist/`, so run `build` first.
88
121
 
89
- <h4>Programmatic API</h4>
122
+ ## How It Works
90
123
 
91
- Advanced users may want to use the library programmatically:
124
+ ### Dev Mode
92
125
 
93
- ```typescript
94
- import { setup, build, dev, serve } from "defuss-ssg";
126
+ `defuss-ssg dev` starts a Vite server rooted at your project. Requests for MD and MDX pages are resolved through Vite's transform pipeline and rendered on demand with SSR. Page, component, endpoint, RPC, config, and asset changes are coalesced before reload. CSS assets are hot-swapped when possible, and hydration boundaries restore local form and scroll state across component updates.
95
127
 
96
- (async () => {
128
+ By default, the CLI keeps `dist/` refreshed during dev as a compatibility fallback for middleware paths. Programmatic users can disable that bridge with `writeDevOutput: false`.
97
129
 
98
- // Setup project initially
99
- const setupStatus = await setup("./my-site");
100
- if (setupStatus.code !== "OK") {
101
- console.error("Setup failed:", setupStatus.message);
102
- process.exit(1);
103
- }
130
+ ### Build Mode
104
131
 
105
- // One-time build
106
- await build({
107
- projectDir: "./my-site",
108
- debug: true,
109
- });
132
+ `defuss-ssg build` loads `config.ts`, copies the project into `.ssg-temp`, renders each page through a temporary Vite SSR server, applies automatic hydration wrapping, bundles client components, compiles endpoints into `.endpoints`, copies assets into `dist`, and removes the temp directory unless debug mode is enabled.
110
133
 
111
- // Or start the Vite-backed dev server
112
- await dev({
113
- projectDir: "./my-site",
114
- debug: true,
115
- });
134
+ ### Serve Mode
116
135
 
117
- // Or serve an already-built production output
118
- await serve({
119
- projectDir: "./my-site",
120
- workers: "auto",
121
- });
122
- })();
123
- ```
136
+ `defuss-ssg serve` reads the built output from `dist/` and serves it with `defuss-express`. Dynamic endpoint modules are registered at runtime, and `rpc.ts` or `rpc.js` is compiled and initialized automatically when RPC is enabled and `defuss-rpc` is installed.
124
137
 
125
- <h3 align="center">
126
- Overview
127
- </h3>
138
+ ## Endpoints
128
139
 
129
- > `defuss-ssg` is a CLI tool and library for building static websites using modern JavaScript/TypeScript and `defuss`. It reads content files (Markdown, MDX) from a specified directory, processes them with MDX plugins, compiles components with esbuild, and outputs fully static HTML sites ready for deployment.
140
+ Endpoint source files live under `pages/` and export HTTP method handlers.
130
141
 
131
- > It supports a plugin system for extending the build process at various phases (pre-build, post-build, page-level transformations), Vite-backed development, and defuss-express production serving.
142
+ ```ts
143
+ import type { APIRoute } from "defuss-ssg";
132
144
 
133
- <h3 align="center">
145
+ export const GET: APIRoute = async () => {
146
+ return Response.json({ ok: true, ts: Date.now() });
147
+ };
148
+ ```
134
149
 
135
- Features
150
+ Supported method exports are `GET`, `POST`, `PUT`, `DELETE`, `PATCH`, `HEAD`, `OPTIONS`, and `ALL`.
136
151
 
137
- </h3>
152
+ Dynamic routes use bracket syntax:
138
153
 
139
- - **MDX Support**: Full Markdown + JSX support with frontmatter parsing
140
- - **Component Integration**: Use defuss components in your MDX files
141
- - **Plugin System**: Extend the build process with custom plugins at multiple phases
142
- - **Fast Compilation**: Powered by esbuild today, with Vite now orchestrating development
143
- - **Dev Mode**: Vite-backed development server with auto-rebuild and full reload
144
- - **Production Runtime**: `defuss-express` serves static output plus dynamic endpoints and RPC
145
- - **TypeScript Ready**: Full TypeScript support for components and configuration
146
- - **Asset Handling**: Automatic copying of static assets to output directory
147
- - **Flexible Configuration**: Configurable via TypeScript config file with sensible defaults
154
+ ```text
155
+ pages/api/[id].json.ts -> /api/:id.json
156
+ pages/feed.xml.ts -> /feed.xml
157
+ ```
148
158
 
149
- <h3 align="center">
159
+ To pre-render an endpoint during `build`, export `prerender = true`. Dynamic routes can also export `getStaticPaths()`.
150
160
 
151
- Example site project structure
161
+ ```ts
162
+ import type { APIRoute } from "defuss-ssg";
152
163
 
153
- </h3>
164
+ export const prerender = true;
154
165
 
155
- Create a project structure like this:
166
+ export const getStaticPaths = () => [
167
+ { params: { slug: "hello-world" } },
168
+ { params: { slug: "release-notes" } },
169
+ ];
156
170
 
157
- ```typescript
158
- my-site/
159
- ├-- pages/
160
- │ ├-- index.mdx
161
- │ └-- blog/
162
- │ └-- hello-world.mdx
163
- ├-- components/
164
- │ └-- button.tsx
165
- ├-- assets/
166
- │ └-- styles.css
167
- └-- config.ts
171
+ export const GET: APIRoute = async ({ params }) => {
172
+ return new Response(`Post: ${params.slug}`);
173
+ };
168
174
  ```
169
- Then run `defuss-ssg build ./my-site` and a `dist` folder will be created with the complete static build.
170
175
 
171
- <h3 align="center">
176
+ ## RPC
172
177
 
173
- Config file
174
-
175
- </h3>
176
-
177
- You can customize the paths and behaviour of the build process, by creating a simple `config.ts` file in the project folder.
178
-
179
- ##### Example `config.ts` file
180
-
181
- ```typescript
182
- import { remarkPlugins, rehypePlugins } from "defuss-ssg";
178
+ RPC is optional and discovered automatically from `rpc.ts` or `rpc.js` in the project root. Install `defuss-rpc` to enable it.
183
179
 
180
+ ```ts
184
181
  export default {
185
- pages: "pages",
186
- output: "dist",
187
- components: "components",
188
- assets: "assets",
189
- remarkPlugins: [...remarkPlugins], // default remark plugins
190
- rehypePlugins: [...rehypePlugins], // default rehype plugins
191
- plugins: [],
182
+ mathApi: {
183
+ add: async (a: number, b: number) => a + b,
184
+ },
185
+ greetApi: {
186
+ hello: async (name: string) => `Hello, ${name}!`,
187
+ },
192
188
  };
193
189
  ```
194
190
 
195
- You may add any `remark` and `rehype` plugin of your choice. See the `MDX` documentation for more informations on Remark and Rehype.
196
-
197
- `defuss-ssg` plugins can be registered via the `plugins` array and are executed in order of registration, in each build phase.
198
-
199
- ##### Example MDX page (`pages/index.mdx`)
200
-
201
- ```mdx
202
- ---
203
- title: Home Page
204
- ---
191
+ When RPC is active, `defuss-ssg` exposes:
205
192
 
206
- import Button from "../components/button.js"
193
+ - `POST /rpc`
194
+ - `POST /rpc/schema`
207
195
 
208
- # Welcome to my site
196
+ Set `rpc: false` in `config.ts` to disable RPC discovery.
209
197
 
210
- This is a **markdown** page with JSX components.
198
+ ## Plugins
211
199
 
212
- <Button>Click me</Button>
213
- ```
200
+ `defuss-ssg` plugins run in build order and can modify the pipeline at distinct phases.
214
201
 
215
- ##### Example Button component (`components/button.tsx`)
202
+ ```ts
203
+ import type { SsgPlugin } from "defuss-ssg";
216
204
 
217
- Components are imported as `.js` but saved as `.tsx`:
205
+ const htmlStampPlugin: SsgPlugin = {
206
+ name: "html-stamp",
207
+ phase: "page-html",
208
+ mode: "both",
209
+ fn: (html, relativeOutputHtmlFilePath) => {
210
+ return html.replace(
211
+ "</body>",
212
+ `<!-- built:${relativeOutputHtmlFilePath} --></body>`,
213
+ );
214
+ },
215
+ };
218
216
 
219
- ```typescript
220
- export const Button = ({ label }: { label: string }) => {
221
- return (
222
- <button type="button" onClick={() => alert("Button clicked!")}>
223
- {label}
224
- </button>
225
- );
217
+ export default {
218
+ plugins: [htmlStampPlugin],
226
219
  };
227
220
  ```
228
221
 
222
+ Available phases:
229
223
 
230
- <h3 align="center">
224
+ - `pre`: before a full build starts
225
+ - `page-vdom`: after page VDOM creation and before render
226
+ - `page-dom`: after DOM render and before serialization
227
+ - `page-html`: after HTML serialization and before write
228
+ - `post`: after the build completes
231
229
 
232
- Plugin System
230
+ `page-vdom` hooks receive the page props/module exports as their fifth argument.
233
231
 
234
- </h3>
232
+ ## Programmatic API
235
233
 
236
- Extend the build process with plugins that run at different phases:
234
+ ```ts
235
+ import { build, dev, serve, setup } from "defuss-ssg";
237
236
 
238
- ```typescript
239
- import { rule, transval, access } from 'defuss-transval';
237
+ const projectDir = "./my-site";
240
238
 
241
- type UserData = {
242
- user: {
243
- profile: {
244
- name: string;
245
- email: string;
246
- settings: {
247
- theme: 'light' | 'dark';
248
- notifications: boolean;
249
- };
250
- };
251
- posts: Array<{
252
- title: string;
253
- published: boolean;
254
- import { SsgPlugin } from "defuss-ssg";
239
+ const setupStatus = await setup(projectDir);
240
+ if (setupStatus.code !== "OK") {
241
+ throw new Error(setupStatus.message);
242
+ }
255
243
 
256
- const myPlugin: SsgPlugin = {
257
- name: "my-plugin",
258
- phase: "page-html", // "pre" | "post" | "page-vdom" | "page-dom" | "page-html"
259
- fn: (html, relativePath, config) => {
260
- // Modify HTML before writing
261
- return html.replace("old-text", "new-text");
262
- },
263
- };
244
+ await build({
245
+ projectDir,
246
+ mode: "build",
247
+ debug: true,
248
+ });
264
249
 
265
- export default {
266
- plugins: [myPlugin],
267
- // ... other config
268
- };
269
- ```
250
+ await dev({
251
+ projectDir,
252
+ port: 3000,
253
+ host: true,
254
+ writeDevOutput: true,
255
+ });
270
256
 
271
- Available plugin phases:
257
+ await serve({
258
+ projectDir,
259
+ port: 3000,
260
+ workers: "auto",
261
+ });
262
+ ```
272
263
 
273
- - **pre**: Before build starts
274
- - **page-vdom**: After VDOM creation for each page
275
- - **page-dom**: After DOM rendering for each page
276
- - **page-html**: After HTML serialization for each page
277
- - **post**: After build completes
264
+ The main package exports `build`, `dev`, `serve`, `setup`, config defaults, endpoint types, RPC helpers, and plugin types.
278
265
 
266
+ Advanced subpath exports:
279
267
 
280
- <h3 align="center">
268
+ - `defuss-ssg/vite`: exposes `defussSsg()` for custom Vite integration
269
+ - `defuss-ssg/runtime`: exposes the client runtime used for navigation, hydration, and live reload
281
270
 
282
- MDX Features
271
+ Most projects only need the main package export.
283
272
 
284
- </h3>
273
+ ## CLI Reference
285
274
 
286
- `defuss-ssg` supports full MDX with `defuss` components and common GFM Markdown features:
275
+ ```bash
276
+ defuss-ssg [dev|build|serve] [folder] [--debug] [--multicore]
287
277
 
288
- - **Frontmatter**: YAML/TOML metadata extraction - the `meta` object holds frontmatter data - use e.g. `{ meta.title }` for page title defined in frontmatter like this:
289
- ```mdx
290
- ---
291
- title: My Page
292
- ---
278
+ No args -> serve .
279
+ Single path -> serve <path>
280
+ Single command -> <command> .
281
+ Command + folder -> <command> <folder>
293
282
  ```
294
283
 
295
- - **JSX Components**: Use `defuss` components in your content
296
- - **Math Support**: KaTeX rendering with `$...$` and `$$...$$`
297
- - **Custom Plugins**: Extend MDX processing with remark/rehype plugins
284
+ Commands:
298
285
 
299
- <h3 align="center">
286
+ - `dev`: starts the Vite dev server on port `3000` by default
287
+ - `build`: generates the static site into `dist/`
288
+ - `serve`: serves the built output from `dist/`
300
289
 
301
- Build Process
290
+ Flags:
302
291
 
303
- </h3>
292
+ - `--debug` or `-d`: enable verbose logging
293
+ - `--multicore`: use `workers: "auto"` for `serve`
304
294
 
305
- The build process follows these steps:
295
+ ## Local Package Development
306
296
 
307
- 1. **Copy Project**: Copy all files to temporary directory
308
- 2. **Compile MDX**: Process MDX files to ESM JavaScript
309
- 3. **Compile Components**: Bundle components with esbuild
310
- 4. **Evaluate Pages**: Run page functions to generate VDOM
311
- 5. **Render HTML**: Convert VDOM to HTML using defuss/server
312
- 6. **Run Plugins**: Execute plugins at various phases
313
- 7. **Copy Assets**: Copy static assets to output
314
- 8. **Clean Up**: Remove temporary files (unless debug mode)
297
+ To work on `defuss-ssg` inside this monorepo:
315
298
 
316
- <h3 align="center">
299
+ ```bash
300
+ git clone https://github.com/kyr0/defuss.git
301
+ cd defuss/packages/ssg
302
+ bun install
303
+ bun run build
304
+ bun run cli-dev
305
+ ```
317
306
 
318
- CLI Reference
307
+ The example project used by the package scripts lives in `../../example-ssg/`.
319
308
 
320
- </h3>
309
+ ## Benchmarking
321
310
 
322
- ```bash
323
- defuss-ssg <command> <folder>
311
+ The benchmark scripts are for local experiments, not committed performance guarantees.
324
312
 
325
- Commands:
326
- build <folder> Build the static site
327
- serve <folder> Serve with auto-rebuild on changes
313
+ ```bash
314
+ bun run bench
315
+ bun run bench:rpc
328
316
  ```
329
317
 
330
- <p align="center">
331
-
332
- <img src="https://raw.githubusercontent.com/kyr0/defuss/refs/heads/main/assets/defuss_comic.png" width="400px" />
333
-
334
- </p>
318
+ Benchmark result snapshots are written to `.tmp/bench-results.json` by default. Override that path with `RESULTS_FILE=/path/to/file.json` if needed.
335
319
 
336
- <p align="center">
337
- <i><b>Come visit us on <code>defuss</code> Island!</b></i>
338
- </p>
320
+ For local load-balancing experiments, use `scripts/lb.ts` directly.
package/dist/cli.mjs CHANGED
@@ -1,16 +1,17 @@
1
1
  #!/usr/bin/env node
2
- import { v as validateProjectDir, b as build } from './vite-DyhxNy3G.mjs';
3
- import { d as dev, s as serve } from './serve-CLC1GbGD.mjs';
2
+ import { v as validateProjectDir, b as build } from './vite-DcjFCDSl.mjs';
3
+ import { d as dev, s as serve } from './serve-CSH82zKY.mjs';
4
4
  import { join, dirname, resolve } from 'node:path';
5
5
  import { existsSync, readFileSync } from 'node:fs';
6
6
  import { spawn } from 'node:child_process';
7
7
  import 'node:fs/promises';
8
+ import 'node:url';
9
+ import 'defuss/server';
10
+ import 'node:crypto';
8
11
  import '@mdx-js/rollup';
9
12
  import 'fast-glob';
10
13
  import 'vite';
11
14
  import 'defuss-vite';
12
- import 'defuss/server';
13
- import 'node:url';
14
15
  import 'node:os';
15
16
  import 'esbuild';
16
17
  import 'rehype-katex';
@@ -21,8 +22,6 @@ import 'remark-gfm';
21
22
  import 'remark-parse';
22
23
  import 'remark-rehype';
23
24
  import 'remark-mdx-frontmatter';
24
- import './tailwind-DV23JSh-.mjs';
25
- import 'node:crypto';
26
25
  import 'defuss-express';
27
26
 
28
27
  const canResolve = (dep, dir) => {
@@ -174,7 +173,7 @@ Continuing anyway - dependencies may already be available.`
174
173
  const debug = args.includes("--debug") || args.includes("-d");
175
174
  const multicore = args.includes("--multicore");
176
175
  const positional = args.filter((a) => !a.startsWith("-"));
177
- const usage = "Usage: defuss-ssg [dev|build|serve] [folder]\n No args \u2192 serve .\n Single path \u2192 serve <path>\n Single command \u2192 <command> .\n Command + folder \u2192 <command> <folder>\n Flags: [--debug] [--multicore]";
176
+ const usage = "Usage: defuss-ssg [dev|build|serve] [folder]\n No args => serve .\n Single path => serve <path>\n Single command => <command> .\n Command + folder => <command> <folder>\n Flags: [--debug] [--multicore]";
178
177
  let command;
179
178
  let folder;
180
179
  if (positional.length === 0) {
package/dist/index.cjs CHANGED
@@ -1,16 +1,17 @@
1
1
  'use strict';
2
2
 
3
- var vite = require('./vite-CPvbAFU5.cjs');
3
+ var vite = require('./vite-CQJBNUfy.cjs');
4
+ var mdx = require('@mdx-js/rollup');
4
5
  var vite$1 = require('vite');
5
6
  var defuss = require('defuss-vite');
6
7
  var node_fs = require('node:fs');
7
8
  var node_path = require('node:path');
8
9
  var defussExpress = require('defuss-express');
9
10
  require('node:fs/promises');
10
- require('@mdx-js/rollup');
11
- require('fast-glob');
12
- require('defuss/server');
13
11
  require('node:url');
12
+ require('defuss/server');
13
+ require('node:crypto');
14
+ require('fast-glob');
14
15
  require('node:os');
15
16
  require('esbuild');
16
17
  require('rehype-katex');
@@ -21,8 +22,6 @@ require('remark-gfm');
21
22
  require('remark-parse');
22
23
  require('remark-rehype');
23
24
  require('remark-mdx-frontmatter');
24
- require('./tailwind-C4AuHybm.cjs');
25
- require('node:crypto');
26
25
 
27
26
  const dev = async ({
28
27
  projectDir,
@@ -33,6 +32,7 @@ const dev = async ({
33
32
  }) => {
34
33
  const projectDirStatus = vite.validateProjectDir(projectDir);
35
34
  if (projectDirStatus.code !== "OK") return projectDirStatus;
35
+ const config = await vite.readConfig(projectDir, debug);
36
36
  const server = await vite$1.createServer({
37
37
  root: projectDir,
38
38
  configFile: false,
@@ -52,6 +52,12 @@ const dev = async ({
52
52
  },
53
53
  plugins: [
54
54
  defuss({ enableJsxDevMode: true }),
55
+ mdx({
56
+ jsxImportSource: "defuss",
57
+ development: true,
58
+ remarkPlugins: config.remarkPlugins,
59
+ rehypePlugins: config.rehypePlugins
60
+ }),
55
61
  ...vite.defussSsg({
56
62
  projectDir,
57
63
  debug,
@@ -59,7 +65,7 @@ const dev = async ({
59
65
  })
60
66
  ]
61
67
  });
62
- await server.listen();
68
+ await server.listen(port);
63
69
  server.printUrls();
64
70
  return {
65
71
  code: "OK",
@@ -185,8 +191,6 @@ exports.loadEndpointModule = vite.loadEndpointModule;
185
191
  exports.matchRoutePattern = vite.matchRoutePattern;
186
192
  exports.readConfig = vite.readConfig;
187
193
  exports.registerEndpoints = vite.registerEndpoints;
188
- exports.rehypePlugins = vite.rehypePlugins;
189
- exports.remarkPlugins = vite.remarkPlugins;
190
194
  exports.resolveEndpoints = vite.resolveEndpoints;
191
195
  exports.routeToExpressPattern = vite.routeToExpressPattern;
192
196
  exports.dev = dev;