I'm playing with Figwheel and writing a simple single-page app that doesn't require any server-side intelligence.
In principle, this app. could be placed on any static web-server.
But how do I actually deploy it? It looks like the main.js which is in my Figwheel development environment is setting up the figwheel connection.
What js and html files do I actually need to put on my static server? Has Figwheel created them, or do I need to create a new main.js and index.html? And where can I find examples?
The documentation is great for how to get started using Figwheel but surprisingly reticent on what to do after you've finished development.
Step 1: Make the production build:
lein do clean, cljsbuild once min
Step 2: Put everything in resources/public
in a publicly accessible place.
Here is the script I use to do this in an example project: https://github.com/timothypratley/whip/blob/master/deploy.sh
The HTML resources don't change between local development and deployment. The only thing that is different are the compiled artifacts. You can deploy in fact development compiled artifacts just fine too. The only reason it is recommended to do a "production build" is that when developing locally the intermediate JS files are not stitched together, because it is faster to load only the changed code into the browser. For deployment, having a single compiled artifact is better. That single compiled JS can have advanced optimizations, or just simple optimizations depending on how you configure the builds in your project.clj. You don't really need to worry about any of this, I'm just explaining because you asked specifically what changes.
It might sound strange that the HTML page doesn't change at all, so lets explain that a little more. The HTML page includes a compiled JS, when you are running figwheel, if you open up that JS you will see it in turn just loads other JS files. But if you exit figwheel and do a clean "production" build, you will see all the code goes into the one JS file. Pretty tricky huh?
That whip project should provide the example you are seeking, please let me know if any of this is unclear.
It uses github pages and the deployment target, but again you just need everything in the resources/public directory hosted somewhere. So you can use a very similar script with any deployment target.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With