Vite 또는 Rollup 플러그인 설치
Astro는 Vite를 기반으로 구축되었으며 Vite 및 Rollup 플러그인을 모두 지원합니다. 이 레시피는 Rollup 플러그인을 사용하여 Astro에서 YAML (.yml) 파일을 가져오는 기능을 추가합니다.
레시피
섹션 제목: “레시피”-
@rollup/plugin-yaml을 설치합니다.터미널 창 npm install @rollup/plugin-yaml --save-dev터미널 창 pnpm add @rollup/plugin-yaml --save-dev터미널 창 yarn add @rollup/plugin-yaml --dev -
astro.config.mjs파일에서 플러그인을 가져와 Vite 플러그인 배열에 추가합니다.astro.config.mjs import { defineConfig } from 'astro/config';import yaml from '@rollup/plugin-yaml';export default defineConfig({vite: {plugins: [yaml()]}}); -
마지막으로
import문을 사용하여 YAML 데이터를 가져올 수 있습니다.import yml from './data.yml';