Skip to content

Commit

Permalink
docs: better explanation for base configuration (#8779)
Browse files Browse the repository at this point in the history
Co-authored-by: Sarah Rainsberger <[email protected]>
  • Loading branch information
ematipico and sarah11918 authored Oct 17, 2023
1 parent fc838c5 commit 2b8a459
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/thin-flies-notice.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'astro': patch
---

Enriches the explanation of the `base` configuration with examples.
23 changes: 22 additions & 1 deletion packages/astro/src/@types/astro.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down

0 comments on commit 2b8a459

Please sign in to comment.