0
# CLI Commands
1
2
Shadow-CLJS provides a comprehensive command-line interface for all development and build operations. Commands are executed through the global `shadow-cljs` binary or npx.
3
4
## Capabilities
5
6
### Compile Command
7
8
Compiles a build once and exits. Used for one-time builds or CI/CD pipelines.
9
10
```bash { .api }
11
shadow-cljs compile <build-id> [options]
12
13
# Options:
14
--debug # Enable debug mode with readable output
15
--pseudo-names # Use pseudo names for debugging
16
--source-maps # Generate source maps
17
--config-merge <edn> # Merge additional configuration
18
--verbose # Enable verbose output
19
```
20
21
**Usage Examples:**
22
23
```bash
24
# Basic compilation
25
shadow-cljs compile app
26
27
# Debug compilation with source maps
28
shadow-cljs compile app --debug --source-maps
29
30
# Compile with additional configuration
31
shadow-cljs compile app --config-merge '{:closure-defines {app.config/DEBUG true}}'
32
```
33
34
### Watch Command
35
36
Starts watching a build for file changes and automatically recompiles. Essential for development workflow.
37
38
```bash { .api }
39
shadow-cljs watch <build-id> [options]
40
41
# Options:
42
--debug # Enable debug mode
43
--verbose # Enable verbose output
44
--sync # Force synchronous compilation
45
--config-merge <edn> # Merge additional configuration
46
```
47
48
**Usage Examples:**
49
50
```bash
51
# Start watching with hot reload
52
shadow-cljs watch app
53
54
# Watch with debug output
55
shadow-cljs watch app --debug --verbose
56
57
# Watch with custom configuration
58
shadow-cljs watch app --config-merge '{:dev-http {8080 \"public\"}}'
59
```
60
61
### Release Command
62
63
Compiles with Google Closure Compiler optimizations enabled for production builds.
64
65
```bash { .api }
66
shadow-cljs release <build-id> [options]
67
68
# Options:
69
--debug # Enable debug mode (disable optimizations)
70
--pseudo-names # Use pseudo names in optimized output
71
--source-maps # Generate source maps for production
72
--config-merge <edn> # Merge additional configuration
73
```
74
75
**Usage Examples:**
76
77
```bash
78
# Production build
79
shadow-cljs release app
80
81
# Production build with source maps
82
shadow-cljs release app --source-maps
83
84
# Debug release build
85
shadow-cljs release app --debug
86
```
87
88
### Check Command
89
90
Performs compilation analysis and error checking without generating output files.
91
92
```bash { .api }
93
shadow-cljs check <build-id> [options]
94
95
# Options:
96
--verbose # Enable verbose output
97
--config-merge <edn> # Merge additional configuration
98
```
99
100
**Usage Examples:**
101
102
```bash
103
# Check for compilation errors
104
shadow-cljs check app
105
106
# Verbose error checking
107
shadow-cljs check app --verbose
108
```
109
110
### Server Commands
111
112
Manages the Shadow-CLJS development server for hot reload and development tools.
113
114
```bash { .api }
115
# Start development server
116
shadow-cljs server [options]
117
118
# Options:
119
--port <number> # Server port (default: 9630)
120
--host <string> # Server host (default: localhost)
121
--config-merge <edn> # Merge additional configuration
122
123
# Stop development server
124
shadow-cljs stop
125
```
126
127
**Usage Examples:**
128
129
```bash
130
# Start server on default port
131
shadow-cljs server
132
133
# Start server on custom port
134
shadow-cljs server --port 8080
135
136
# Start server with custom configuration
137
shadow-cljs server --config-merge '{:dev-http {3000 \"public\"}}'
138
139
# Stop running server
140
shadow-cljs stop
141
```
142
143
### REPL Commands
144
145
Interactive Read-Eval-Print Loop for development and debugging.
146
147
```bash { .api }
148
# Build-specific REPL
149
shadow-cljs repl <build-id>
150
151
# Node.js REPL
152
shadow-cljs node-repl [options]
153
# Options:
154
--config-merge <edn> # Merge additional configuration
155
156
# Browser REPL
157
shadow-cljs browser-repl [options]
158
# Options:
159
--config-merge <edn> # Merge additional configuration
160
161
# Connect to ClojureScript REPL
162
shadow-cljs cljs-repl <build-id>
163
```
164
165
**Usage Examples:**
166
167
```bash
168
# Start REPL for browser build
169
shadow-cljs repl app
170
171
# Start Node.js REPL for server-side development
172
shadow-cljs node-repl
173
174
# Start browser REPL for general ClojureScript development
175
shadow-cljs browser-repl
176
177
# Connect to existing build REPL
178
shadow-cljs cljs-repl app
179
```
180
181
### Information Commands
182
183
Commands for inspecting build state and project information.
184
185
```bash { .api }
186
# Show build information
187
shadow-cljs info [build-id]
188
189
# Show project classpath
190
shadow-cljs classpath
191
192
# Generate Maven POM file
193
shadow-cljs pom
194
195
# Show version information
196
shadow-cljs --version
197
198
# Show help
199
shadow-cljs help [command]
200
```
201
202
**Usage Examples:**
203
204
```bash
205
# Show all builds information
206
shadow-cljs info
207
208
# Show specific build information
209
shadow-cljs info app
210
211
# Show project classpath
212
shadow-cljs classpath
213
214
# Show help for a specific command
215
shadow-cljs help watch
216
```
217
218
### Testing Commands
219
220
Execute ClojureScript tests in different environments.
221
222
```bash { .api }
223
# Run Node.js tests
224
shadow-cljs node-test [test-build-id] [options]
225
226
# Run Karma tests (browser)
227
shadow-cljs karma [test-build-id] [options]
228
229
# Generic test command
230
shadow-cljs test [options]
231
232
# Options:
233
--config-merge <edn> # Merge additional configuration
234
--autorun # Enable automatic test running
235
```
236
237
**Usage Examples:**
238
239
```bash
240
# Run Node.js tests
241
shadow-cljs node-test test
242
243
# Run browser tests with Karma
244
shadow-cljs karma test
245
246
# Run generic test command
247
shadow-cljs test
248
249
# Run tests with automatic rerun
250
shadow-cljs node-test test --autorun
251
```
252
253
### Advanced Commands
254
255
Specialized commands for advanced use cases and debugging.
256
257
```bash { .api }
258
# Tree shaking analysis
259
shadow-cljs tree-shake <build-id>
260
261
# Dependency analysis
262
shadow-cljs deps [options]
263
264
# Clean compiled files
265
shadow-cljs clean [build-id]
266
267
# REPL for specific namespaces
268
shadow-cljs clj-repl
269
270
# nREPL server
271
shadow-cljs nrepl
272
273
# Server management commands
274
shadow-cljs start # Start development server
275
shadow-cljs stop # Stop development server
276
shadow-cljs restart # Restart development server
277
278
# Project initialization
279
shadow-cljs init # Initialize new shadow-cljs project
280
281
# AOT compilation
282
shadow-cljs aot # Ahead-of-time compilation
283
```
284
285
**Usage Examples:**
286
287
```bash
288
# Analyze unused code
289
shadow-cljs tree-shake app
290
291
# Clean all build outputs
292
shadow-cljs clean
293
294
# Clean specific build
295
shadow-cljs clean app
296
297
# Start Clojure REPL
298
shadow-cljs clj-repl
299
300
# Server management
301
shadow-cljs start
302
shadow-cljs stop
303
shadow-cljs restart
304
305
# Initialize new project
306
shadow-cljs init
307
308
# AOT compilation
309
shadow-cljs aot
310
```