0.1.0 • Published 9 years ago
cljsbuild v0.1.0
Cljsbuild
A simple Clojurescript build tool for Nodejs.
Features
- simple
- build cljs
- launch a tty cljs repl
- launch an nrepl server
- with figwheel support (
cljsbuild nrepl -f) - store config and maven deps in package.json
- works with npm scripts
Installation
You need at least node v6.9.4
npm install cljsbuild --save-devCljsbuild also needs Java (for the Clojurescript compiler and repl/nrepl) and
Maven2 for Java dependency management (apt install maven2).
New Project Setup
- Generate a new package.json with
npm init - Install cljsbuild, a static http server, a copy-and-watch tool and a command runner:
npm install cljsbuild http-server cpx concurrently --save-dev - Add cljsbuild configuration by calling
node_modules/.bin/cljsbuild init --figwheel - Run
node_modules/.bin/cljsbuild install - Create a
src/app/core.cljsfile:(ns app.core) - Edit
package.jsoncljsbuildmainto matchapp.core - Create an
html/index.htmlfile to load the cljs app:<!doctype html><html><body><script src="js/main.js"></script></body></html> - Add an entry to
package.jsonscripts:"repl": "concurrently --kill-others --raw 'http-server -c-1 --silent -p 8080 build 0<&-' 'cpx html/index.html build --watch 0<&-' 'cljsbuild repl --figwheel'" - Run
npm run repland wait around 1 minute for the cljs compiler to compile everything, make sure port 8080 is not in use - After
Prompt will show when Figwheel connects to your applicationshows up, open http://localhost:8080 - Happy Hacking!
Check the simple fighwheel example.
Example Usage
cljsbuild -h # help screen
cljsbuild # install dependencies and build
cljsbuild repl # start a cljs repl
cljsbuild nrepl -f # start an nrepl server and provide a start-repl function that launches figwheelConfiguration
Cljsbuild reads its config from the cljsbuild key in package.json:
cljsbuild: {
main: "my-app-namespace.core" # cljs main namespace
src: "src" # cljs source directory
depedencies: { # cljs dependencies fetched via maven
"org.clojure/clojure": "1.7.0",
"org.clojure/clojurescript": "1.7.170",
<...>
}
}Run node_modules/.bin/cljsbuild init to initialize the config,
node_modules/.bin/cljsbuild update to update any maven dependencies.
Scripting
Use npm scripts to assemble cljsbuild and other tools:
"scripts": {
"build-production": "cljsbuild --production",
"dev-nrepl": "paralellshell 'http-server -c-1 --silent' 'cljsbuild nrepl'"
}and invoke them on the commandline
$ npm run dev-nrepl