Reputation: 3036
How do i host the browser build?
I do not get it, i run: npx shadow-cljs release app
npm start? node app.js is wrong I cannot launch app.js in the browser. What am i doing wrong?
My shadow-cljs.edn looks like this:
{:source-paths ["src"]
:dependencies [[binaryage/devtools "1.0.6"]
[nrepl "0.9.0"]
[reagent "1.1.1"]]
:builds {:app {:target :browser
:output-dir "public/js"
:asset-path "/js"
:modules {:app {:entries [simpletodo.core]}}
:devtools {:after-load simpletodo.core/mount-root}}}
:dev-http {3000 {:root "public"
:handler user/app}}}
One level higher, i would think the index.html could be the right one, but it looks like this.
I even put in this HTML file and started the HTML, but it would not work. All i get is a white page:
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="/css/main.css">
<title>Browser Starter</title>
</head>
<body>
<h1>shadow-cljs - Browser</h1>
<div id="app"></div>
<noscript>You need to enable JavaScript to run this app.</noscript>
<script src="/public/js/app.js"></script>
</body>
</html>
Upvotes: 0
Views: 303
Reputation: 4356
Can you clarify what you mean by "hosting the build"?
If you are just testing stuff you can run npx shadow-cljs server
(and keep it running) which will also run the :dev-http
servers in the build config. So your files would be accessible via http://localhost:3000, just like they would be with a running watch
.
A release
build produces an optimized .js
file. shadow-cljs
is not used in production environments and is out of the picture after producing the files.
Any webserver capable of serving static files will work at that point. Common options include nginx, apache or just a CLJ webserver (eg. jetty).
Upvotes: 3