Skip to content

Commit bb36013

Browse files
committed
chore(client): don't overwrite built client when running playground
1 parent ad5b781 commit bb36013

2 files changed

Lines changed: 11 additions & 5 deletions

File tree

β€Žclient/bootstrap.tsβ€Ž

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { existsSync } from 'node:fs'
12
import { createResolver, defineNuxtModule } from '@nuxt/kit'
23
import { startSubprocess } from '@nuxt/devtools-kit'
34

@@ -14,6 +15,9 @@ interface DevtoolsReadyContext {
1415
export default defineNuxtModule((_, nuxt) => {
1516
if (!nuxt.options.dev || !nuxt.options.modules?.includes('@nuxt/fonts')) return
1617

18+
// A prebuilt client takes precedence in `src/devtools.ts`
19+
if (existsSync(resolver.resolve('../dist/client/index.html'))) return
20+
1721
const command = {
1822
command: 'npx',
1923
args: ['nuxt', 'dev', '--port', DEVTOOLS_UI_PORT.toString()],

β€Žclient/nuxt.config.tsβ€Ž

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,13 @@ const resolver = createResolver(import.meta.url)
55

66
export default defineNuxtConfig({
77
modules: ['@unocss/nuxt'],
8+
$production: {
9+
nitro: {
10+
output: {
11+
publicDir: resolver.resolve('../dist/client'),
12+
},
13+
},
14+
},
815
ssr: false,
916
app: {
1017
baseURL: DEVTOOLS_UI_PATH,
@@ -18,11 +25,6 @@ export default defineNuxtConfig({
1825
resolver.resolve('./assets/styles.css'),
1926
],
2027
compatibilityDate: '2024-08-19',
21-
nitro: {
22-
output: {
23-
publicDir: resolver.resolve('../dist/client'),
24-
},
25-
},
2628
vite: {
2729
// microlighter loads TextMate grammars with `import(`./grammars/${lang}.js`)`. Dep pre-bundling
2830
// rewrites that to a path with no grammars beside it, and the dynamic-import-vars transform

0 commit comments

Comments
Β (0)