安装 Vite 或 Rollup 插件
Astro 构建在 Vite 之上,并支持 Vite 和 Rollup 插件。本秘诀使用 Rollup 插件添加在 Astro 中导入 YAML (.yml
) 文件的功能。
¥Astro builds on top of Vite, and supports both Vite and Rollup plugins. This recipe uses a Rollup plugin to add the ability to import a YAML (.yml
) file in Astro.
秘诀
标题部分 秘诀¥Recipe
-
Install
@rollup/plugin-yaml
: -
Import the plugin in your
astro.config.mjs
and add it to the Vite plugins array: -
Finally, you can import YAML data using an
import
statement: