0

How do i host the browser build?

I do not get it, i run: npx shadow-cljs release app

enter image description here

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.

enter image description here

I even put in this HTML file and started the HTML, but it would not work. All i get is a white page:

enter image description here ➜ simpletodo cat index.html

<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>
Denis Fuenzalida
  • 3,271
  • 1
  • 17
  • 22
David
  • 2,926
  • 1
  • 27
  • 61
  • 1
    In the second screenshot it tells you to run `npx shadow-cljs watch app`. On the console it will tell you that a web server will be ready on port 8080, so you can open your app on `http://localhost:8080`. Feel free to look on this example project: https://github.com/dfuenzalida/fabric-todos – Denis Fuenzalida Jun 25 '22 at 03:26
  • @DenisFuenzalida Ah okay, that mean i build with :browser for the internal shadow-cljs webserver? – David Jun 25 '22 at 09:28
  • 1
    **DO NOT post images of code, data, error messages, etc.** - copy or type the text into the question. [ask] – Rob Jun 25 '22 at 12:51

1 Answers1

3

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).

Thomas Heller
  • 3,842
  • 1
  • 9
  • 9