Tích hợp Astro
Tích hợp UnoCSS cho Astro: @unocss/astro. Xem ví dụ.
Cài đặt
bash
pnpm add -D unocssbash
yarn add -D unocssbash
npm install -D unocssbash
bun add -D unocssts
import { defineConfig } from 'astro/config'
import UnoCSS from 'unocss/astro'
export default defineConfig({
integrations: [
UnoCSS(),
],
})Tạo tệp uno.config.ts:
ts
import { defineConfig } from 'unocss'
export default defineConfig({
// ...UnoCSS options
})Đặt lại kiểu (Style Reset)
Theo mặc định, đặt lại kiểu trình duyệt sẽ không được chèn vào. Để bật nó, hãy cài đặt gói @unocss/reset:
bash
pnpm add -D @unocss/resetbash
yarn add -D @unocss/resetbash
npm install -D @unocss/resetbash
bun add -D @unocss/resetVà cập nhật astro.config.ts của bạn:
ts
import { defineConfig } from 'astro/config'
import UnoCSS from 'unocss/astro'
export default defineConfig({
integrations: [
UnoCSS({
injectReset: true // or a path to the reset file
}),
],
})Sử dụng không cần preset
Plugin này không đi kèm bất kỳ preset mặc định nào.
bash
pnpm add -D @unocss/astrobash
yarn add -D @unocss/astrobash
npm install -D @unocss/astrobash
bun add -D @unocss/astrots
import UnoCSS from '@unocss/astro'
export default {
integrations: [
UnoCSS(),
],
}Để biết thêm chi tiết, vui lòng tham khảo Vite plugin.
INFO
Nếu bạn đang xây dựng một meta framework trên UnoCSS, xem tệp này để biết ví dụ về cách liên kết các preset mặc định.
Lưu ý
Các thành phần client:only phải được đặt trong thư mục components hoặc được thêm vào cấu hình content của UnoCSS để được xử lý.