vitePluginChromedevtools() — astro Function Reference
Architecture documentation for the vitePluginChromedevtools() function in index.ts from the astro codebase.
Entity Profile
Dependency Diagram
graph TD 162b4cb6_b14a_260f_aea2_20bd03563315["vitePluginChromedevtools()"] 99f1c803_6a67_9071_3256_0a49371b7fad["index.ts"] 162b4cb6_b14a_260f_aea2_20bd03563315 -->|defined in| 99f1c803_6a67_9071_3256_0a49371b7fad style 162b4cb6_b14a_260f_aea2_20bd03563315 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
packages/astro/src/vite-plugin-chromedevtools/index.ts lines 12–60
export function vitePluginChromedevtools({ settings }: Payload): Plugin {
return {
name: 'astro:chromedevtools',
configureServer(viteServer) {
// Chrome DevTools workspace handler
// See https://chromium.googlesource.com/devtools/devtools-frontend/+/main/docs/ecosystem/automatic_workspace_folders.md
viteServer.middlewares.use(async function chromeDevToolsHandler(request, response, next) {
if (request.url !== '/.well-known/appspecific/com.chrome.devtools.json') {
return next();
}
if (!settings.config.experimental.chromeDevtoolsWorkspace) {
// Return early to stop console spam
response.writeHead(404);
response.end();
return;
}
const pluginVersion = '1.1';
const cacheDir = settings.config.cacheDir;
const configPath = new URL('./chrome-workspace.json', cacheDir);
if (!existsSync(cacheDir)) {
await mkdir(cacheDir, { recursive: true });
}
let config;
try {
config = JSON.parse(await readFile(configPath, 'utf-8'));
// If the cached workspace config was created with a previous version of this plugin,
// we throw an error so it gets recreated in the `catch` block below.
if (config.version !== pluginVersion) throw new Error('Cached config is outdated.');
} catch {
config = {
workspace: {
version: pluginVersion,
uuid: crypto.randomUUID(),
root: fileURLToPath(settings.config.root),
},
};
await writeFile(configPath, JSON.stringify(config));
}
response.setHeader('Content-Type', 'application/json');
response.end(JSON.stringify(config));
return;
});
},
};
}
Domain
Subdomains
Source
Frequently Asked Questions
What does vitePluginChromedevtools() do?
vitePluginChromedevtools() is a function in the astro codebase, defined in packages/astro/src/vite-plugin-chromedevtools/index.ts.
Where is vitePluginChromedevtools() defined?
vitePluginChromedevtools() is defined in packages/astro/src/vite-plugin-chromedevtools/index.ts at line 12.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free