CSS Modules with Clojurescript

538 views
Skip to first unread message

Dhruv Bhatia

unread,
Nov 6, 2015, 7:24:59 AM11/6/15
to ClojureScript
Hi All,

Curious to know whether anyone has successfully built a CLJS workflow for using CSS Modules within Clojurescript:

http://glenmaddern.com/articles/css-modules

It looks like a really solid way to write maintainable CSS, but I haven't been able to find any references to Clojure based workflows.

I'm specifically interested in understanding how one can include CSS modules within CLJS where we don't have a bundle tool like Browserify to also process the CLJS file itself.

I'm thinking about using something like Gulp to build and watch my css files, outputting a bundle which I can then reference within my CLJS file - but not sure whether that will work as the JS examples seem to "import" the CSS modules directly in order to get the references to the style names.

Will give it a go and see where I get, but any thoughts would be appreciated.

Dhruv Bhatia

unread,
Nov 7, 2015, 10:21:50 AM11/7/15
to ClojureScript

Good news - I managed to get this working using a Gulp/Browserify compile process which builds a CommonJS module that is consumed by my CLJS project (using foreign-libs). I can then use the generated CSS Module class names within my CLJS files. It works with live-reloading through figwheel too, so quite happy.

There were a few quirks with getting it all working, so If anyone is interested, I can clean up the code and create a sample GitHub project.

Stephen Gilardi

unread,
Nov 7, 2015, 2:13:54 PM11/7/15
to clojur...@googlegroups.com

On Nov 7, 2015, at 10:21 AM, Dhruv Bhatia <dh...@dhruvbhatia.com> wrote:

There were a few quirks with getting it all working, so If anyone is interested, I can clean up the code and create a sample GitHub project.

I’d appreciate seeing that!

—Steve

Dhruv Bhatia

unread,
Nov 7, 2015, 6:36:05 PM11/7/15
to ClojureScript
Sure! See https://github.com/dhruvbhatia/clojurescript-css-modules-demo for a quick sample project.
Let me know if you have any issues - I plan on expanding on the documentation and improving structure shortly.
Reply all
Reply to author
Forward
0 new messages