Skip to content

Instantly share code, notes, and snippets.

@roman01la
Created April 25, 2020 14:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save roman01la/cede7b4826c9ceb73427ae82b39af319 to your computer and use it in GitHub Desktop.
Save roman01la/cede7b4826c9ceb73427ae82b39af319 to your computer and use it in GitHub Desktop.
mkdir hello-bundler
cd hello-bundler
echo '{:deps {org.clojure/clojurescript {:mvn/version "1.10.741"}}}' > deps.edn
yarn add webpack webpack-cli react react-dom --save-dev
mkdir -p src/hello_bundler
;; src/hello_bundler/core.cljs
(ns hello-bundler.core
  (:require [react]
            [react-dom]))

(def h1 (react/createElement "h1" nil "Hello!"))

(react-dom/render h1 (.getElementById js/document "root"))
echo '<div id="root"></div><script src="bundle.js"></script>' > index.html
;; webpack.config.js
module.exports = {
  entry: "./out/index.js",
  output: {
    path: __dirname,
    filename: "bundle.js"
  }
}
;; build.edn
{:main hello-bundler.core
 :output-to "out/index.js"
 :output-dir "out"
 :target :bundle
 :bundle-cmd {:none ["npx" "webpack" "--mode=development"]
              :default ["npx" "webpack"]}}
clj -m cljs.main -co build.edn --compile --repl
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment