Leiningen template for reagent web apps which implement the re-frame pattern.
Through the use of profiles, this template lets the developer pick and choose what "extras" are included in their application.
The base template includes:
To create an application with the base template:
lein new re-frame <project-name>
Troubleshooting note: for
<project-name>
don't usecljs
. That name will confuse the compiler and you will (later) see errors likecljs.core.init is not a function
The optional profiles include:
+10x
)+re-frisk
)+handler
)+re-com
)+re-pressed
)+breaking-point
)+routes
)To add a profile to the base template, just append the profile name (let's use +re-com
as an example):
lein new re-frame <project-name> +re-com
Any combination of profiles can be added at once:
lein new re-frame <project-name> +garden +re-com +routes +test +less +10x
Note: to assist debugging, you'll want to include either
+10x
or+re-frisk
Refer to the shadow-cljs Emacs / CIDER documentation.
The mentioned dir-local.el
file is created by this template.
Compile css file once.
lein garden once
lein less once
Automatically recompile css file on change.
lein garden auto
lein less auto
Retrieve dependencies:
lein deps
yarn install # or npm install
Then run:
lein clean
lein dev
Wait a bit, then browse to http://localhost:8280.
To see other available shadow-cljs commands run:
lein run -m shadow.cljs.devtools.cli --help
So, you now have the application running.
Before you start developing, you should tweak two settings within your
browser's devtools
. These are one-time actions (for each browser and laptop you use).
I'll assume Chrome for the purposes of further explanation:
F12
or Ctrl-Shift-i
(actually there's a variety of ways)To use re-frame-10x
for debugging your app:
Ctrl-H
and you should see the re-frame-10x
panel appear on the right side of the windowSometimes achieving Step 1 on a really simple app - one without widgets - can be fiddly,
because the browser itself hogs "input focus" and grabs all the keystrokes (like Ctrl-H
) which don't
then make it through to your app. You may need to be determined and creative with Step 1.
I have every confidence in you.
If you now edit files, like perhaps /src/cljs/<project-name>/views.cljs
, Figwheel will automatically
recompile your changes and "hot load" them into your running app, without your app needing
to be re-started. The resulting fast, iterative workflow tends to make you very productive, and
is cherished by those lucky enough to experience it.
In project-name.config, there is a variable called debug?
, which
defaults to true. However, for the min
build (look inside of project.clj
), this variable is
re-defined to false.
When debug?
is true, we include (enable-console-print!)
. If you, for example,
you wrap your println
s with a when
block as show below, then you will get logs
printed to the browser's console for the dev
build and not the min
build.
(when config/debug?
(println "dev mode"))
Install karma and headless chrome
npm install -g karma-cli
And then run your tests
lein clean
lein run -m shadow.cljs.devtools.cli compile karma-test
karma start --single-run --reporters junit,dots
To compile clojurescript to javascript:
lein clean
lein prod
+handler
)Create uberjar
lein clean
lein with-profile prod uberjar
Create app on heroku
heroku create
Then deploy the application
git push heroku master
Looking for more re-frame inspiration, templates or example applications? See the external resources docs page.
Contributions are welcomed! To add a new profile, this is what I'd recommend:
lein install
lein new re-frame <app-name> +<profile-name>
The MIT License (MIT)
Copyright © 2015 Matthew Jaoudi
Copyright © 2015 Dylan Paris
Copyright © 2015 Michael Thompson
Copyright © 2015 Markku Rontu
Copyright © 2016 Daniel Compton
Copyright © 2019 Isaac Johnston
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
Can you improve this documentation? These fine people already did:
Matthew Jaoudi, Mike Thompson, matthew, Dylan Paris, Stuart Mitchell, David Goldfarb, motor4ik, Isaac Johnston, Bheesham Persaud, Matthieu Béteille, Mattew Jaoudi, Caleb Black, Andrew Neverov, Markku Rontu, Siegfried Ehret & Jakub DundalekEdit on GitHub
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close