CLI UnoCSS
Interfejs wiersza poleceń dla UnoCSS: @unocss/cli.
- 🍱 Odpowiedni dla tradycyjnych backendów jak Laravel lub Kirby
- 👀 Tryb obserwacji włączony
- 🔌 Obsługuje niestandardowe konfiguracje przez
uno.config.ts
Instalacja
Ten pakiet jest dostarczany z pakietem unocss:
pnpm add -D unocssyarn add -D unocssnpm install -D unocssbun add -D unocssMożesz również zainstalować samodzielny pakiet:
pnpm add -D @unocss/cliyarn add -D @unocss/clinpm install -D @unocss/clibun add -D @unocss/cliINFO
Jeśli nie możesz znaleźć pliku binarnego (np. z pnpm i zainstalowany jest tylko unocss), musisz zainstalować samodzielny pakiet @unocss/cli.
Użycie
Możesz również przekazać wiele wzorców glob do @unocss/cli:
unocss "site/snippets/**/*.php" "site/templates/**/*.php"Przykładowa konfiguracja pakietu:
INFO
Upewnij się, że dodałeś cytowane wzorce glob do skryptu npm.
{
"scripts": {
"dev": "unocss \"site/{snippets,templates}/**/*.php\" --watch",
"build": "unocss \"site/{snippets,templates}/**/*.php\""
},
"devDependencies": {
"@unocss/cli": "latest"
}
}Development
Add the --watch (or -w) flag to enable watching for file changes:
unocss "site/{snippets,templates}/**/*.php" --watchProduction
unocss "site/{snippets,templates}/**/*.php"The final uno.css will be generated to the current directory by default.
Built-in features
Configurations
Create a uno.config.js or uno.config.ts configuration file the root-level of your project to customize UnoCSS.
import { defineConfig } from 'unocss'
export default defineConfig({
cli: {
entry: {}, // CliEntryItem | CliEntryItem[]
},
// ...
})
interface CliEntryItem {
/**
* Glob patterns to match files
*/
patterns: string[]
/**
* The output filename for the generated UnoCSS file
*/
outFile: string
}For a list of options, head over to the UnoCSS configurations docs.
Options
| Options | |
|---|---|
-v, --version | Display the current version of UnoCSS |
-c, --config-file <file> | Config file |
-o, --out-file <file> | The output filename for the generated UnoCSS file. Defaults to uno.css in the current working directory |
--stdout | Write the generated UnoCSS file to STDOUT. Will cause the --watch and --out-file being ignored |
-w, --watch | Indicates if the files found by the glob pattern should be watched |
--preflights | Enable preflight styles |
--write-transformed | Update source files with transformed utilities |
-m, --minify | Minify generated CSS |
-h, --help | Display available CLI options |