Skip to content

Commit 468feb1

Browse files
committed
Make browser, library, node targets available
1 parent e8c26f2 commit 468feb1

File tree

9 files changed

+1091
-36
lines changed

9 files changed

+1091
-36
lines changed

minimal-shadow-cljs-nodejs/README.md

+45-14
Original file line numberDiff line numberDiff line change
@@ -7,47 +7,78 @@ Node.js example with ClojureScript with [shadow-cljs](https://github.com/thhelle
77

88
### Develop
99

10-
Watch compile with with hot reloading:
10+
Install all dependencies.
1111

1212
```bash
1313
npm run install
14-
npm run watch
14+
```
15+
16+
Watch compile with with hot reloading, using the `browser` target as example.
17+
18+
```
19+
npm run watch:browser
1520
```
1621

1722
Start program and connect reload server:
1823

1924
```bash
20-
npm start
25+
npm run start:browser
2126
```
2227

23-
### REPL
28+
### Production release
2429

25-
Start a REPL connected to current running program, `app` for the `:build-id`:
30+
Build production builds for each target.
2631

2732
```bash
28-
npx shadow-cljs cljs-repl app
33+
# Build all targets
34+
npm run release
35+
# or
36+
npm run release:app
37+
npm run release:library
38+
npm run release:browser
2939
```
3040

31-
### Build
41+
#### Browser
42+
43+
```
44+
npm run release:browser
45+
```
46+
47+
This will generate a file inside `build/browser/browser-main.js`, and copy a static `index.html` which loads the script.
48+
49+
The `browser-main.js` file contains your JavaScript logic, so copy that into your server and load it into your main website HTML.
50+
51+
- [Browser target](https://shadow-cljs.github.io/docs/UsersGuide.html#target-browser)
52+
53+
#### Node application
3254

33-
```bash
34-
npm run build
55+
```
56+
npm run release:app
3557
```
3658

37-
Compiles to `build/main.js`.
59+
Compiles the Node app, `:app` target, to `build/node-app.js`.
3860

39-
You may find more configurations on http://doc.shadow-cljs.org/ .
61+
- [Node application target](https://shadow-cljs.github.io/docs/UsersGuide.html#target-node-script)
4062

41-
### Build the library
63+
#### Library
4264

43-
Apart from the main Node script/app generated, we can also generate a library in the standard `commonjs` format that can be used in other Node projects, or as a handler in AWS Lambda.
65+
Apart from the main Node script/app generated, we can also generate a library in the standard `commonjs` format that can be used in other Node/JavaScript projects, or as a handler in AWS Lambda.
4466

4567
```
46-
npm run build:lib
68+
npm run release:library
4769
```
4870

71+
- [Node library target](https://shadow-cljs.github.io/docs/UsersGuide.html#target-node-library)
4972
- [Multiple named exports](https://shadow-cljs.github.io/docs/UsersGuide.html#_multiple_static_named_exports)
5073

74+
### REPL
75+
76+
Start a REPL connected to current running program, `app` for the `:build-id`:
77+
78+
```bash
79+
npx shadow-cljs cljs-repl app
80+
```
81+
5182
### Run a script on the command line before building
5283

5384
Using [Lumo-cljs](https://github.com/anmonteiro/lumo) allows us to run scripts before fully building with `shadow-cljs` to test things out.

0 commit comments

Comments
 (0)