You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+33-28Lines changed: 33 additions & 28 deletions
Original file line number
Diff line number
Diff line change
@@ -46,53 +46,58 @@ The app is only a very basic skeleton with the most useful development tools con
46
46
`shadow-cljs` is configured by the `shadow-cljs.edn` config. It looks like this:
47
47
48
48
```clojure
49
-
{:source-paths
50
-
["src"] ;; .cljs files go here
49
+
;; shadow-cljs configuration
50
+
{:source-paths; .cljs files go here
51
+
["src/dev"
52
+
"src/main"
53
+
"src/test"]
51
54
52
-
:dependencies
53
-
[] ;; covered later
55
+
:dependencies; covered later
56
+
[]
57
+
58
+
:dev-http; starts a http dev server on http://localhost:8020 and serves `public`
59
+
{8020"public"}
54
60
55
61
:builds
56
-
{:app {:target:browser
57
-
:output-dir"public/js"
58
-
:asset-path"/js"
59
-
60
-
:modules
61
-
{:main;; <- becomes public/js/main.js
62
-
{:entries [starter.browser]}}
63
-
64
-
;; start a development http server on http://localhost:8020
65
-
:devtools
66
-
{:http-root"public"
67
-
:http-port8020}
68
-
}}}
62
+
{:app; build identifier
63
+
{:target:browser
64
+
:output-dir"public/js"
65
+
:asset-path"/js"
66
+
67
+
:modules
68
+
{:main; becomes public/js/main.js
69
+
{:init-fn starter.browser/init}}}}}
70
+
69
71
```
70
72
71
73
It defines the `:app` build with the `:target` set to `:browser`. All output will be written to `public/js` which is a path relative to the project root (ie. the directory the `shadow-cljs.edn` config is in).
72
74
73
75
`:modules` defines the how the output should be bundled together. For now we just want one file. The `:main` module will be written to `public/js/main.js`, it will include the code from the `:entries` and all their dependencies.
74
76
75
-
`:devtools` configures some useful development things. The `http://localhost:8020` server we used earlier is controlled by the `:http-port` and serves the `:http-root` directory.
76
-
77
-
The last part is the actual `index.html` that is loaded when you open `http://localhost:8020`. It loads the generated `/js/main.js` and then calls `start.browser.init` which we defined in the `src/start/browser.cljs`.
77
+
The last part is the actual `index.html` that is loaded when you open `http://localhost:8020`. It loads the generated `/js/main.js` and then calls `start.browser.init` which we defined in the `src/main/start/browser.cljs`.
This can now be used to eval code in the browser (assuming you still have it open). Try `(js/alert "Hi.")` and take it from there. You might want to use `rlwrap npx shadow-cljs cljs-repl app` if you intend to type a lot here.
0 commit comments