Created
June 1, 2017 05:52
-
-
Save thheller/9ea396698520cf7448b3f7bcff4b7df6 to your computer and use it in GitHub Desktop.
webpack config written in CLJS
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[{: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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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