or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

Files

docs

cli.mderrors.mdindex.mdprogrammatic.mdwatching.md

cli.mddocs/

0

# Command Line Interface

1

2

Full-featured CLI for CSS generation with extensive configuration options including watch mode, custom output paths, and transformer support.

3

4

## Capabilities

5

6

### Start CLI

7

8

Initializes and starts the CLI application with command-line argument parsing and option handling.

9

10

```typescript { .api }

11

/**

12

* Initializes and starts the CLI application with command parsing

13

* @param cwd - Working directory (defaults to process.cwd())

14

* @param argv - Command line arguments (defaults to process.argv)

15

* @param options - Default CLI options to merge with command arguments

16

* @returns Promise that resolves when CLI processing completes

17

*/

18

function startCli(

19

cwd?: string,

20

argv?: string[],

21

options?: CliOptions

22

): Promise<void>;

23

```

24

25

**Usage Examples:**

26

27

```typescript

28

// Note: startCli may not be directly exported from main package entry

29

// Check package build outputs for correct import path

30

import { startCli } from "@unocss/cli";

31

32

// Start with default process arguments

33

await startCli();

34

35

// Start with custom working directory

36

await startCli("/path/to/project");

37

38

// Start with custom arguments

39

await startCli(

40

process.cwd(),

41

["", "", "src/**/*.html", "-o", "dist/styles.css", "--watch"]

42

);

43

44

// Start with default options

45

await startCli(process.cwd(), process.argv, {

46

outFile: "uno.css",

47

preflights: true,

48

});

49

```

50

51

## CLI Command Format

52

53

The CLI accepts glob patterns and various options:

54

55

```bash

56

unocss [...patterns] [options]

57

```

58

59

### Command Arguments

60

61

- `[...patterns]` - One or more glob patterns for files to process

62

63

### Command Options

64

65

- `-o, --out-file <file>` - Output CSS file path (defaults to "uno.css" in current directory)

66

- `--stdout` - Output CSS to STDOUT instead of file

67

- `-c, --config [file]` - Path to UnoCSS configuration file

68

- `-w, --watch` - Enable watch mode for automatic rebuilding

69

- `--write-transformed` - Update source files with transformed utilities

70

- `--preflights` - Enable CSS preflights (default: true)

71

- `-m, --minify` - Minify generated CSS output

72

73

### CLI Examples

74

75

```bash

76

# Basic CSS generation

77

unocss "src/**/*.html"

78

79

# Custom output file

80

unocss "src/**/*.html" --out-file dist/styles.css

81

82

# Multiple file patterns

83

unocss "src/**/*.html" "src/**/*.js" --out-file build/uno.css

84

85

# Watch mode for development

86

unocss "src/**/*.{html,js,ts}" --watch --out-file dist/uno.css

87

88

# Output to stdout for piping

89

unocss "src/**/*.html" --stdout > styles.css

90

91

# Use custom configuration

92

unocss "src/**/*.html" --config uno.config.ts

93

94

# Minified output

95

unocss "src/**/*.html" --minify --out-file dist/uno.min.css

96

97

# Transform source files in place

98

unocss "src/**/*.html" --write-transformed

99

100

# Disable preflights

101

unocss "src/**/*.html" --no-preflights

102

```

103

104

### Configuration File Integration

105

106

The CLI integrates with UnoCSS configuration files and supports multi-entry configurations:

107

108

```javascript

109

// uno.config.js

110

import { defineConfig } from 'unocss'

111

112

export default defineConfig({

113

cli: {

114

entry: [

115

{

116

patterns: ['src/pages/**/*.html'],

117

outFile: 'dist/pages.css',

118

},

119

{

120

patterns: ['src/components/**/*.js'],

121

outFile: 'dist/components.css',

122

},

123

],

124

},

125

// ... other UnoCSS configuration

126

})

127

```

128

129

When using configuration files, the CLI will process multiple entry points automatically:

130

131

```bash

132

# Processes all entries defined in config

133

unocss --config uno.config.js

134

```