Closed vemv closed 1 year ago
Kit is generally agnostic regarding the asset pipeline. Optimus should work with Kit more or less out of the box.
The only change I'd recommend from the workflow described in the docs would be to specify the middleware for loading assets in development and productions under env/dev/clj/<your ns>/env.clj
and env/prod/clj/<your ns>/env.clj
. For example, Optimus has the following code for selecting the asset loading strategy:
(-> app
(optimus/wrap ;; 14
get-assets ;; 15
(if (= :dev (:env config)) ;; 16
optimizations/none ;; 17
optimizations/all) ;; 18
(if (= :dev (:env config)) ;; 19
strategies/serve-live-assets ;; 20
strategies/serve-frozen-assets)) ;; 21
(ring.middleware.content-type/wrap-content-type) ;; 22
(ring.middleware.not-modified/wrap-not-modified))
So you could use optimizations/none
in dev and optimizations/all
in prod, same with strategies/serve-live-assets
and strategies/serve-frozen-assets
. This way you don't need a runtime flag to select which middleware should be loaded.
You can also add a step in build.clj
to do any processing of the assets that needs to be done when the app is packaged.
Nice!
Thank you.
I'll add any worthwhile observation if found later.
Hi!
I wonder what the Kit view is when it comes to a Rails-like asset pipeline. i.e. production assets should have a content digest appended to their filename.
There's https://github.com/magnars/optimus and https://github.com/circleci/stefon.
Have you had a successful integration with either?
Or is there a more Kit-idiomatic approach?
Cheers - V