devtools-json
The devtools-json 插件安装了 vite-plugin-devtools-json,这是一个用于在开发服务器上实时生成 Chromium DevTools 项目设置文件的 Vite 插件。此文件从 /.well-known/appspecific/com.chrome.devtools.json 提供服务,并告知 Chromium 浏览器您的项目源代码的位置,以便您可以使用 工作区功能 在浏览器中编辑源文件。
[!注意] 安装此插件将启用所有使用 Chromium 浏览器连接到开发服务器的用户的功能,并允许浏览器读取和写入目录中的所有文件。如果使用 Chrome 的 AI 辅助功能,这也可能导致数据被发送到 Google。
替代方案
如果您不想安装插件,但又想避免看到关于缺失文件的提示,您有几个选择。
首先,您可以通过在浏览器中禁用功能来防止您的机器发出请求。您可以在 Chrome 中通过访问chrome://flags并禁用“开发者工具项目设置”来实现这一点。您可能还对禁用“开发者工具自动工作区文件夹”感兴趣,因为它与之密切相关。
您也可以通过自行处理请求来防止 Web 服务器向您的应用程序的所有开发者发出有关传入请求的通知。例如,您可以创建一个名为 .well-known/appspecific/com.chrome.devtools.json 的文件,内容为"Go away, Chrome DevTools!",或者您可以在您的handle钩子中添加逻辑来响应请求:
import { const dev: booleanWhether the dev server is running. This is not guaranteed to correspond to NODE_ENV or MODE.
dev } from '$app/environment';
export function function handle({ event, resolve }: {
event: any;
resolve: any;
}): any
handle({ event: anyevent, resolve: anyresolve }) {
if (const dev: booleanWhether the dev server is running. This is not guaranteed to correspond to NODE_ENV or MODE.
dev && event: anyevent.url.pathname === '/.well-known/appspecific/com.chrome.devtools.json') {
return new var Response: new (body?: BodyInit | null, init?: ResponseInit) => ResponseThis Fetch API interface represents the response to a request.
Response(var undefinedundefined, { ResponseInit.status?: number | undefinedstatus: 404 });
}
return resolve: anyresolve(event: anyevent);
}使用
npx sv add devtools-json您将获得
vite-plugin-devtools-json添加到您的 Vite 插件选项中
Edit this page on GitHub llms.txt