Skip to content

Instantly share code, notes, and snippets.

@thheller
Created June 1, 2017 05:52
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 thheller/9ea396698520cf7448b3f7bcff4b7df6 to your computer and use it in GitHub Desktop.
Save thheller/9ea396698520cf7448b3f7bcff4b7df6 to your computer and use it in GitHub Desktop.
webpack config written in CLJS
[{:id :webpack
:target :node-library
:output-to "webpack.config.js"
:exports config.webpack/exports
:devtools
{:enabled false}}]
;; then shadow-cljs --build webpack --dev|--once
;; webpack -d
;; webpack -p
;; webpack --watch
(ns config.webpack
(:require ["path" :as path]))
;; this gets called by webpack and should return the config
(defn configure [env opts]
;; opts contains useful things, like "watch":true|false
(let [{:strs [watch] :as opts} (js->clj opts)]
;; (prn opts)
(-> {:entry
{:react ["react" "react-dom"]}
:output
{:path (path/resolve "dist")
:filename "bundle.js"}}
(clj->js))))
;; this is a bit ugly, need to adjust :node-library to directly export a default
;; it only supports objects or calling functions currently
(defn exports []
configure)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment