$service-worker
import { const base: stringThe base path of the deployment. Typically this is equivalent to config.kit.paths.base, but it is calculated from location.pathname meaning that it will continue to work correctly if the site is deployed to a subdirectory.
Note that there is a base but no assets, since service workers cannot be used if config.kit.paths.assets is specified.
base, const build: string[]An array of URL strings representing the files generated by Vite, suitable for caching with cache.addAll(build).
During development, this is an empty array.
build, const files: string[]An array of URL strings representing the files in your static directory, or whatever directory is specified by config.kit.files.assets. You can customize which files are included from static directory using config.kit.serviceWorker.files
files, const prerendered: string[]An array of pathnames corresponding to prerendered pages and endpoints.
During development, this is an empty array.
prerendered, const version: stringSee config.kit.version. It’s useful for generating unique cache names inside your service worker, so that a later deployment of your app can invalidate old caches.
version } from '$service-worker';此模块仅对服务工作者可用。
基础
部署的基本路径。通常这等同于config.kit.paths.base,但它是由location.pathname计算得出的,这意味着如果网站部署到子目录中,它仍然可以正确工作。请注意,存在一个基本但没有资源,因为如果指定了config.kit.paths.assets,则无法使用服务工作者。
const base: string;构建
一个表示由 Vite 生成的文件的 URL 字符串数组,适用于与 cache.addAll(build) 一起缓存。在开发期间,这是一个空数组。
const build: string[];文件
一个表示您静态目录中文件的 URL 字符串数组,或由config.kit.files.assets指定的任何目录。您可以使用 config.kit.serviceWorker.files 自定义从static目录中包含哪些文件。
const 文件: string[];
预渲染
路径名数组,对应预渲染页面和端点。在开发期间,这是一个空数组。
const prerendered: string[];版本
查看 config.kit.version。这对于在您的服务工作者内部生成唯一的缓存名称很有用,以便您的应用程序的后续部署可以使旧缓存失效。
const 版本:string;
Edit this page on GitHub llms.txt