Skip to main content

devtools-json

devtools-json 插件会安装 vite-plugin-devtools-json,这是一个 Vite 插件,用于在开发服务器中动态生成 Chromium DevTools 项目设置文件。此文件由 /.well-known/appspecific/com.chrome.devtools.json 提供,并告知 Chromium 浏览器项目源代码所在的位置,以便你可以使用 工作区功能 在浏览器中编辑源文件。

¥The devtools-json add-on installs vite-plugin-devtools-json, which is a Vite plugin for generating a Chromium DevTools project settings file on-the-fly in the development server. This file is served from /.well-known/appspecific/com.chrome.devtools.json and tells Chromium browsers where your project’s source code lives so that you can use the workspaces feature to edit source files in the browser.

安装此插件后,所有使用 Chromium 浏览器连接到开发服务器的用户均可使用该功能,并允许浏览器读写目录中的所有文件。如果使用 Chrome 的 AI 辅助功能,则数据也可能会发送到 Google。

替代方案(Alternatives)

¥Alternatives

如果你不想安装该插件,但仍想避免看到有关文件丢失的消息,你有以下几种选择。

¥If you’d prefer not to install the plugin, but still want to avoid seeing a message about the missing file, you have a couple of options.

首先,你可以通过在浏览器中禁用该功能来阻止在你的计算机上发出请求。你可以在 Chrome 中访问 chrome://flags 并禁用 “DevTools 项目设置” 来执行此操作。你可能还想禁用 “DevTools 自动工作区文件夹”,因为它与 密切相关。

¥Firstly, you can prevent the request from being issued on your machine by disabling the feature in your browser. You can do this in Chrome by visiting chrome://flags and disabling the “DevTools Project Settings”. You may also be interested in disabling “DevTools Automatic Workspace Folders” since it’s closely related.

你还可以通过自行处理请求,阻止 Web 服务器向应用的所有开发者发出有关传入请求的通知。例如,你可以创建一个名为 .well-known/appspecific/com.chrome.devtools.json 的文件,其中包含 "Go away, Chrome DevTools!" 的内容,或者你​​可以在 handle 钩子中添加逻辑来响应请求:

¥You can also prevent the web server from issuing a notice regarding the incoming request for all developers of your application by handling the request yourself. For example, you can create a file named .well-known/appspecific/com.chrome.devtools.json with the contents "Go away, Chrome DevTools!" or you can add logic to respond to the request in your handle hook:

src/hooks.server
import { const dev: boolean

Whether 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: boolean

Whether 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) => Response

This Fetch API interface represents the response to a request.

MDN Reference

Response
(var undefinedundefined, { ResponseInit.status?: number | undefinedstatus: 404 });
} return resolve: anyresolve(event: anyevent); }

用法(Usage)

¥Usage

npx sv add devtools-json

你将获得什么(What you get)

¥What you get

  • vite-plugin-devtools-json 已添加到你的 Vite 插件选项中

    ¥vite-plugin-devtools-json added to your Vite plugin options

上一页 下一页