From e4abb7645484ec36719adf88677c8b1f818bc438 Mon Sep 17 00:00:00 2001 From: Evan You Date: Sat, 11 Mar 2023 21:38:57 +0800 Subject: [PATCH] docs: more details on where to place header config --- docs/guide/asset-handling.md | 8 ++++---- docs/guide/deploy.md | 4 ++++ 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/docs/guide/asset-handling.md b/docs/guide/asset-handling.md index 0ba57d75..711be2d1 100644 --- a/docs/guide/asset-handling.md +++ b/docs/guide/asset-handling.md @@ -10,19 +10,19 @@ You can reference static assets in your markdown files, your `*.vue` components Common image, media, and font filetypes are detected and included as assets automatically. -All referenced assets, including those using absolute paths, will be copied to the dist folder with a hashed file name in the production build. Never-referenced assets will not be copied. Image assets smaller than 4kb will be base64 inlined - this can be configured via the [`vite`](../reference/site-config#vite) config option. +All referenced assets, including those using absolute paths, will be copied to the output directory with a hashed file name in the production build. Never-referenced assets will not be copied. Image assets smaller than 4kb will be base64 inlined - this can be configured via the [`vite`](../reference/site-config#vite) config option. All **static** path references, including absolute paths, should be based on your working directory structure. ## Public Files -Sometimes you may need to provide static assets that are not directly referenced in any of your Markdown or theme components (for example, favicons and PWA icons). The `public` directory under project root (`docs` folder if you're running `vitepress build docs`) can be used as an escape hatch to provide static assets that either are never referenced in source code (e.g. `robots.txt`), or must retain the exact same file name (without hashing). +Sometimes you may need to provide static assets that are not directly referenced in any of your Markdown or theme components (for example, favicons and PWA icons). The `public` directory under [project root](./routing#project-root) (`docs` folder if you're running `vitepress build docs`) can be used as an escape hatch to provide static assets that either are never referenced in source code (e.g. `robots.txt`), or must retain the exact same file name (without hashing). -Assets placed in `public` will be copied to the root of the dist directory as-is. +Assets placed in `public` will be copied to the root of the output directory as-is. Note that you should reference files placed in `public` using root absolute path - for example, `public/icon.png` should always be referenced in source code as `/icon.png`. -There is one exception to this: if you have an HTML page in `public` and link to it from the main site, the router will yield a 404 by default. To get around this, VitePress provides a `pathname://` protocol which allows you to link to another page in the same domain as if the link is external. Contrast these two links: +There is one exception to this: if you have an HTML page in `public` and link to it from the main site, the router will yield a 404 by default. To get around this, VitePress provides a `pathname://` protocol which allows you to link to another page in the same domain as if the link is external. Compare these two links: - [/pure.html](/pure.html) - diff --git a/docs/guide/deploy.md b/docs/guide/deploy.md index 69762c63..564681f4 100644 --- a/docs/guide/deploy.md +++ b/docs/guide/deploy.md @@ -73,6 +73,8 @@ Cache-Control: max-age=31536000,immutable cache-control: immutable ``` +Note: the `_headers` file should be placed in the [public directory](/guide/asset-handling#public-files) - in our case, `docs/public/_headers` - so that it is copied verbatim to the output directory. + [Netlify custom headers documentation](https://docs.netlify.com/routing/headers/) ::: @@ -95,6 +97,8 @@ Cache-Control: max-age=31536000,immutable } ``` +Note: the `vercel.json` file should be placed at the root of your **repository**. + [Vercel documentation on headers config](https://vercel.com/docs/concepts/projects/project-configuration#headers) :::