diff options
author | 2023-10-17 17:06:12 +0100 | |
---|---|---|
committer | 2023-10-17 17:06:12 +0100 | |
commit | 2b8a459a6ae82c7a1d278ef263e316841295e7d6 (patch) | |
tree | 6b9f244f0e30a95775cf6435e301edd27d9076e3 | |
parent | fc838c5564cf84c1340d3568373ad24b8193b7e8 (diff) | |
download | astro-2b8a459a6ae82c7a1d278ef263e316841295e7d6.tar.gz astro-2b8a459a6ae82c7a1d278ef263e316841295e7d6.tar.zst astro-2b8a459a6ae82c7a1d278ef263e316841295e7d6.zip |
docs: better explanation for `base` configuration (#8779)
Co-authored-by: Sarah Rainsberger <sarah@rainsberger.ca>
-rw-r--r-- | .changeset/thin-flies-notice.md | 5 | ||||
-rw-r--r-- | packages/astro/src/@types/astro.ts | 23 |
2 files changed, 27 insertions, 1 deletions
diff --git a/.changeset/thin-flies-notice.md b/.changeset/thin-flies-notice.md new file mode 100644 index 000000000..25c543ff7 --- /dev/null +++ b/.changeset/thin-flies-notice.md @@ -0,0 +1,5 @@ +--- +'astro': patch +--- + +Enriches the explanation of the `base` configuration with examples. diff --git a/packages/astro/src/@types/astro.ts b/packages/astro/src/@types/astro.ts index 45a82b355..8741b4074 100644 --- a/packages/astro/src/@types/astro.ts +++ b/packages/astro/src/@types/astro.ts @@ -580,7 +580,28 @@ export interface AstroUserConfig { * * When using this option, all of your static asset imports and URLs should add the base as a prefix. You can access this value via `import.meta.env.BASE_URL`. * - * The value of `import.meta.env.BASE_URL` respects your `trailingSlash` config and will include a trailing slash if you explicitly include one or if `trailingSlash: "always"` is set. If `trailingSlash: "never"` is set, `BASE_URL` will not include a trailing slash, even if `base` includes one. + * The value of `import.meta.env.BASE_URL` will be determined by your `trailingSlash` config, no matter what value you have set for `base`. + * + * A trailing slash is always included if `trailingSlash: "always"` is set. If `trailingSlash: "never"` is set, `BASE_URL` will not include a trailing slash, even if `base` includes one. + * + * Additionally, Astro will internally manipulate the configured value of `config.base` before making it available to integrations. The value of `config.base` as read by integrations will also be determined by your `trailingSlash` configuration in the same way. + * + * In the example below, the values of `import.meta.env.BASE_URL` and `config.base` when processed will both be `/docs`: + * ```js + * { + * base: '/docs/', + * trailingSlash: "never" + * } + * ``` + * + * In the example below, the values of `import.meta.env.BASE_URL` and `config.base` when processed will both be `/docs/`: + * + * ```js + * { + * base: '/docs', + * trailingSlash: "always" + * } + * ``` */ base?: string; |