Skip to content

Commit d614d02

Browse files
committed
fix(plugin-inspect): fix connection meta fetch error during dev
Adds a guard to the distDir assignment to prevent the devframe dev server from crashing when the SPA isn't built yet, and configures the vite plugin properly in the SPA's vite config to start the backend dev server.
1 parent d563268 commit d614d02

2 files changed

Lines changed: 7 additions & 2 deletions

File tree

plugins/inspect/src/index.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import type { DevframeDefinition } from 'devframe/types'
2+
import { existsSync } from 'node:fs'
23
import { fileURLToPath } from 'node:url'
34
import { defineDevframe } from 'devframe/types'
45
import { setupInspect } from './node/index'
@@ -48,7 +49,7 @@ export function createInspectDevframe(options: InspectDevframeOptions = {}): Dev
4849
cli: {
4950
command: id,
5051
port: options.port ?? 9012,
51-
distDir,
52+
distDir: existsSync(distDir) ? distDir : undefined,
5253
// A single-user localhost inspector: skip the trust handshake so
5354
// the SPA's shared-state subscription initializes without a manual
5455
// auth round-trip. Hosted adapters (Vite/hub) supply their own

plugins/inspect/src/spa/vite.config.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { fileURLToPath } from 'node:url'
22
import vue from '@vitejs/plugin-vue'
33
import { defineConfig } from 'vite'
44
import { alias } from '../../../../alias'
5+
import { inspectVitePlugin } from '../vite'
56

67
// The inspector SPA. `base: './'` keeps every asset URL relative so the
78
// bundle is mount-path portable — it discovers its runtime base from
@@ -11,7 +12,10 @@ export default defineConfig({
1112
base: './',
1213
root: fileURLToPath(new URL('.', import.meta.url)),
1314
resolve: { alias },
14-
plugins: [vue()],
15+
plugins: [
16+
vue(),
17+
inspectVitePlugin({ devMiddleware: true, base: '/' })
18+
],
1519
build: {
1620
outDir: fileURLToPath(new URL('../../dist/spa', import.meta.url)),
1721
emptyOutDir: true,

0 commit comments

Comments
 (0)