forked from withastro/docs
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
4.5 minor release docs (withastro#7250)
Co-authored-by: delucis <[email protected]> Co-authored-by: sarah11918 <[email protected]> Co-authored-by: Sarah Rainsberger <[email protected]> Co-authored-by: Bjorn Lu <[email protected]> Co-authored-by: Erika <[email protected]> Co-authored-by: Matthew Phillips <[email protected]> Co-authored-by: Arsh <[email protected]> Co-authored-by: Elian <[email protected]> Co-authored-by: Oliver Speir <[email protected]>
- Loading branch information
1 parent
6d02645
commit 697a7c0
Showing
10 changed files
with
198 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -492,18 +492,18 @@ Specifies the directory in the build output where Astro-generated assets (bundle | |
|
||
<p> | ||
|
||
**Type:** `string`<br /> | ||
**Type:** `string | Record.<string, string>`<br /> | ||
**Default:** `undefined`<br /> | ||
<Since v="2.2.0" /> | ||
</p> | ||
|
||
Specifies the prefix for Astro-generated asset links. This can be used if assets are served from a different domain than the current site. | ||
|
||
For example, if this is set to `https://cdn.example.com`, assets will be fetched from `https://cdn.example.com/_astro/...` (regardless of the `base` option). | ||
You would need to upload the files in `./dist/_astro/` to `https://cdn.example.com/_astro/` to serve the assets. | ||
The process varies depending on how the third-party domain is hosted. | ||
This requires uploading the assets in your local `./dist/_astro` folder to a corresponding `/_astro/` folder on the remote domain. | ||
To rename the `_astro` path, specify a new directory in `build.assets`. | ||
|
||
To fetch all assets uploaded to the same domain (e.g. `https://cdn.example.com/_astro/...`), set `assetsPrefix` to the root domain as a string (regardless of your `base` configuration): | ||
|
||
```js | ||
{ | ||
build: { | ||
|
@@ -512,6 +512,24 @@ To rename the `_astro` path, specify a new directory in `build.assets`. | |
} | ||
``` | ||
|
||
**Added in:** `[email protected]` | ||
|
||
You can also pass an object to `assetsPrefix` to specify a different domain for each file type. | ||
In this case, a `fallback` property is required and will be used by default for any other files. | ||
|
||
```js | ||
{ | ||
build: { | ||
assetsPrefix: { | ||
'js': 'https://js.cdn.example.com', | ||
'mjs': 'https://js.cdn.example.com', | ||
'css': 'https://css.cdn.example.com', | ||
'fallback': 'https://cdn.example.com' | ||
} | ||
} | ||
} | ||
``` | ||
|
||
### build.serverEntry | ||
|
||
<p> | ||
|
@@ -890,7 +908,7 @@ Shiki configuration options. See [the Markdown configuration docs](/en/guides/ma | |
</p> | ||
|
||
Which syntax highlighter to use, if any. | ||
- `shiki` - use the [Shiki](https://github.com/shikijs/shiki) highlighter | ||
- `shiki` - use the [Shiki](https://shiki.style) highlighter | ||
- `prism` - use the [Prism](https://prismjs.com/) highlighter | ||
- `false` - do not apply syntax highlighting. | ||
|
||
|
@@ -1127,25 +1145,29 @@ in the latest version, so that you can continue to upgrade and take advantage of | |
Astro offers experimental flags to give users early access to new features. | ||
These flags are not guaranteed to be stable. | ||
|
||
### experimental.optimizeHoistedScript | ||
### experimental.directRenderScript | ||
|
||
<p> | ||
|
||
**Type:** `boolean`<br /> | ||
**Default:** `false`<br /> | ||
<Since v="2.10.4" /> | ||
<Since v="4.5.0" /> | ||
</p> | ||
|
||
Prevents unused components' scripts from being included in a page unexpectedly. | ||
The optimization is best-effort and may inversely miss including the used scripts. Make sure to double-check your built pages | ||
before publishing. | ||
Enable hoisted script analysis optimization by adding the experimental flag: | ||
Enables a more reliable strategy to prevent scripts from being executed in pages where they are not used. | ||
|
||
Scripts will directly render as declared in Astro files (including existing features like TypeScript, importing `node_modules`, | ||
and deduplicating scripts). You can also now conditionally render scripts in your Astro file. | ||
However, this means scripts are no longer hoisted to the `<head>` and multiple scripts on a page are no longer bundled together. | ||
If you enable this option, you should check that all your `<script>` tags behave as expected. | ||
|
||
This option will be enabled by default in Astro 5.0. | ||
|
||
```js | ||
{ | ||
experimental: { | ||
optimizeHoistedScript: true, | ||
}, | ||
experimental: { | ||
directRenderScript: true, | ||
}, | ||
} | ||
``` | ||
|
||
|
@@ -1168,6 +1190,53 @@ Enables a persistent cache for content collections when building in static mode. | |
} | ||
``` | ||
|
||
### experimental.contentCollectionJsonSchema | ||
|
||
<p> | ||
|
||
**Type:** `boolean`<br /> | ||
**Default:** `false`<br /> | ||
<Since v="4.5.0" /> | ||
</p> | ||
|
||
This feature will auto-generate a JSON schema for content collections of `type: 'data'` which can be used as the `$schema` value for TypeScript-style autocompletion/hints in tools like VSCode. | ||
|
||
To enable this feature, add the experimental flag: | ||
|
||
```diff | ||
import { defineConfig } from 'astro/config'; | ||
export default defineConfig({ | ||
experimental: { | ||
+ contentCollectionJsonSchema: true | ||
} | ||
}); | ||
``` | ||
|
||
This experimental implementation requires you to manually reference the schema in each data entry file of the collection: | ||
|
||
```diff | ||
// src/content/test/entry.json | ||
{ | ||
+ "$schema": "../../../.astro/collections/test.schema.json", | ||
"test": "test" | ||
} | ||
``` | ||
|
||
Alternatively, you can set this in your [VSCode `json.schemas` settings](https://code.visualstudio.com/docs/languages/json#_json-schemas-and-settings): | ||
|
||
```diff | ||
"json.schemas": [ | ||
{ | ||
"fileMatch": [ | ||
"/src/content/test/**" | ||
], | ||
"url": "../../../.astro/collections/test.schema.json" | ||
} | ||
] | ||
``` | ||
|
||
Note that this initial implementation uses a library with [known issues for advanced Zod schemas](https://github.com/StefanTerdell/zod-to-json-schema#known-issues), so you may wish to consult these limitations before enabling the experimental flag. | ||
|
||
### experimental.clientPrerender | ||
|
||
<p> | ||
|
@@ -1179,7 +1248,7 @@ Enables a persistent cache for content collections when building in static mode. | |
|
||
Enables pre-rendering your prefetched pages on the client in supported browsers. | ||
|
||
This feature uses the experimental [Speculation Rules Web API](https://developer.mozilla.org/en-US/docs/Web/API/Speculation_Rules_API) and overrides the default `prefetch` behavior globally to prerender links on the client. | ||
This feature uses the experimental [Speculation Rules Web API](https://developer.mozilla.org/en-US/docs/Web/API/Speculation_Rules_API) and enhances the default `prefetch` behavior globally to prerender links on the client. | ||
You may wish to review the [possible risks when prerendering on the client](https://developer.mozilla.org/en-US/docs/Web/API/Speculation_Rules_API#unsafe_prefetching) before enabling this feature. | ||
|
||
Enable client side prerendering in your `astro.config.mjs` along with any desired `prefetch` configuration options: | ||
|
Oops, something went wrong.