Skip to content

Integracja Astro

Integracja UnoCSS dla Astro: @unocss/astro. Zobacz przykład.

Instalacja

bash
pnpm add -D unocss
bash
yarn add -D unocss
bash
npm install -D unocss
bash
bun add -D unocss
ts
import { defineConfig } from 'astro/config'
import UnoCSS from 'unocss/astro'

export default defineConfig({
  integrations: [
    UnoCSS(),
  ],
})

Utwórz plik uno.config.ts:

ts
import { defineConfig } from 'unocss'

export default defineConfig({
  // ...Opcje UnoCSS
})

Reset stylów

Domyślnie reset stylów przeglądarki nie zostanie wstrzyknięty. Aby go włączyć, zainstaluj pakiet @unocss/reset:

bash
pnpm add -D @unocss/reset
bash
yarn add -D @unocss/reset
bash
npm install -D @unocss/reset
bash
bun add -D @unocss/reset

I zaktualizuj swój astro.config.ts:

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
    }),
  ],
})

Usage without presets

This plugin does not come with any default presets.

bash
pnpm add -D @unocss/astro
bash
yarn add -D @unocss/astro
bash
npm install -D @unocss/astro
bash
bun add -D @unocss/astro
ts
import UnoCSS from '@unocss/astro'

export default {
  integrations: [
    UnoCSS(),
  ],
}

For more details, please refer to the Vite plugin.

INFO

If you are building a meta framework on top of UnoCSS, see this file for an example on how to bind the default presets.

Notes

client:only components must be placed in components folder or added to UnoCSS's content config in order to be processed.

Released under the MIT License.