Skip to content

Commit c33f2af

Browse files
chore(web): add chrome devtools automatic workspace support
Generate /.well-known/appspecific/com.chrome.devtools.json in dev mode to enable automatic workspace folder detection in Chrome DevTools. Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 4fc70b1 commit c33f2af

File tree

1 file changed

+24
-1
lines changed

1 file changed

+24
-1
lines changed

packages/nextclade-web/config/next/next.config.ts

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { config as loadEnv } from 'dotenv'
22
import { NextConfig } from 'next'
3+
import { v5 as uuidv5 } from 'uuid'
34
import getWithMDX from '@next/mdx'
45
import remarkBreaks from 'remark-breaks'
56
import remarkImages from 'remark-images'
@@ -108,6 +109,11 @@ const nextConfig: NextConfig = {
108109
poweredByHeader: false,
109110
transpilePackages: ['auspice', 'debug', 'jotai-devtools', 'semver'],
110111
env,
112+
rewrites: !PRODUCTION
113+
? async () => [
114+
{ source: '/.well-known/appspecific/:path*', destination: '/_next/static/.well-known/appspecific/:path*' },
115+
]
116+
: undefined,
111117
}
112118

113119
const withExternals = getWithExternals({ externals: ['canvas'] })
@@ -159,6 +165,22 @@ const withRobotsTxt = getWithEmitFile({
159165
hash: false,
160166
})
161167

168+
const withDevToolsJson = !PRODUCTION
169+
? getWithEmitFile({
170+
path: 'static/.well-known/appspecific/',
171+
filename: 'com.chrome.devtools.json',
172+
content: (() => {
173+
const UUID_NAMESPACE_URL = '6ba7b811-9dad-11d1-80b4-00c04fd430c8'
174+
return JSON.stringify(
175+
{ workspace: { root: moduleRoot, uuid: uuidv5(moduleRoot, UUID_NAMESPACE_URL) } },
176+
null,
177+
2,
178+
)
179+
})(),
180+
hash: false,
181+
})
182+
: undefined
183+
162184
const plugins = [
163185
withIgnore,
164186
withExternals,
@@ -174,6 +196,7 @@ const plugins = [
174196
withWasm,
175197
withAppJson,
176198
withRobotsTxt,
177-
].filter(Boolean)
199+
...(withDevToolsJson ? [withDevToolsJson] : []),
200+
]
178201

179202
export default () => plugins.reduce((acc, next) => next(acc), nextConfig)

0 commit comments

Comments
 (0)