File tree Expand file tree Collapse file tree 1 file changed +26
-0
lines changed Expand file tree Collapse file tree 1 file changed +26
-0
lines changed Original file line number Diff line number Diff line change @@ -173,3 +173,29 @@ clj -M -m cljs.main -co build.edn -O advanced -v -c -s
173
173
```
174
174
175
175
That's it!
176
+
177
+ [[webworkers]]
178
+ == Building Webworkers
179
+
180
+ When building webworkers with `:target :bundle`, you use webpack (or your
181
+ preferred bundler) to add the webworker bootstrap.
182
+
183
+ So your build's `:target` will still be `:bundle` (not `:webworker`), but you
184
+ will tell your bundler to build a webworker. For example, with webpack you add the
185
+ `--target=webworker` argument to your `:bundle-cmd` entries.
186
+
187
+ You also need to define `cljs.core/*global*` as `"self"` (as opposed to
188
+ `"window"` in browser builds).
189
+
190
+ An example `build-webworker.edn` might look like:
191
+
192
+ [source,clojure]
193
+ ```
194
+ {:main hello-bundler.webworker
195
+ :output-to "out/worker/index.js"
196
+ :output-dir "out/worker"
197
+ :target :bundle
198
+ :bundle-cmd {:none ["npx" "webpack" "out/worker/index.js" "-o" "out/worker/main.js" "--target=webworker" "--mode=development"]
199
+ :default ["npx" "webpack" "out/worker/index.js" "-o" "out/worker/main.js" "--target=webworker"]}
200
+ :closure-defines {cljs.core/*global* "self"}} ;; needed for advanced
201
+ ```
You can’t perform that action at this time.
0 commit comments