Skip to content

Commit 5b24411

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 825a8de commit 5b24411

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'
@@ -132,6 +133,11 @@ const nextConfig: NextConfig = {
132133
'semver',
133134
],
134135
env,
136+
rewrites: !PRODUCTION
137+
? async () => [
138+
{ source: '/.well-known/appspecific/:path*', destination: '/_next/static/.well-known/appspecific/:path*' },
139+
]
140+
: undefined,
135141
}
136142

137143
const withExternals = getWithExternals({ externals: ['canvas'] })
@@ -183,6 +189,22 @@ const withRobotsTxt = getWithEmitFile({
183189
hash: false,
184190
})
185191

192+
const withDevToolsJson = !PRODUCTION
193+
? getWithEmitFile({
194+
path: 'static/.well-known/appspecific/',
195+
filename: 'com.chrome.devtools.json',
196+
content: (() => {
197+
const UUID_NAMESPACE_URL = '6ba7b811-9dad-11d1-80b4-00c04fd430c8'
198+
return JSON.stringify(
199+
{ workspace: { root: moduleRoot, uuid: uuidv5(moduleRoot, UUID_NAMESPACE_URL) } },
200+
null,
201+
2,
202+
)
203+
})(),
204+
hash: false,
205+
})
206+
: undefined
207+
186208
const plugins = [
187209
withIgnore,
188210
withExternals,
@@ -198,6 +220,7 @@ const plugins = [
198220
withWasm,
199221
withAppJson,
200222
withRobotsTxt,
201-
].filter(Boolean)
223+
...(withDevToolsJson ? [withDevToolsJson] : []),
224+
]
202225

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

0 commit comments

Comments
 (0)