Closed tuhlmann closed 8 years ago
Sorry for the late reply, I just tried this with a test project and I wasn't able to reproduce the issue. I have the following setup:
:plugins [[lein-asset-minifier "0.2.8"]]
:minify-assets
{:assets
{"resources/public/css/site.min.css" "resources/public/css"}}
When I run lein minify-assets
, then the minified css is produced as expected. And I'm able to use the hook :hooks [minify-assets.plugin/hooks]
for doing minification when the uberjar is created.
I did some more tests in the mean time. I think it's related to the way I call the plugin. I use a modified Chestnut
template and added a call the minifier to its run
method:
(defn assets-config []
(->> "project.clj"
slurp
read-string
(drop-while #(not= :minify-assets %))
second))
(defn run-minify []
(let [cfg (assets-config)
assets (:assets cfg)
options (:options cfg)]
(future
(Thread/sleep 800)
(log/info "Minifying assets.")
(minify assets options))))
When calling the new version view lein
it did work I recall, using this mechanism did not. I was not able to just call lein minify-assets
from the run
method as I would for sass and others, that threw some other error.
Anyway, the above way works with the old version (0.1.7) but not with the new one...
Hmm not sure why this would be affected. However, if you're running directly from code it might be easier to use the asset-minifier lib directly instead of going through the lein plugin.
That code snippet does use asset-minifier (0.1.7) directly. I removed lein-minify-assets from the dependencies (which I keep to be able to run it from the cmd line) and updated the minifier to 0.1.8 and again it does not create an output file (no error though). When reverting to 0.1.7 it runs as normal.
Maybe it's a dependency problem? When using lein minify-assets
it runs the minifier with the closure compiler bundled in the plugin (in its own jvm). When runnning it together with the rest maybe it uses another version of whatever?
BTW. using the latest lein minify-assets
plugin from the command line works perfectly fine. So I guess this ticket should transition from here to the library.
Yeah sounds like the issue should be moved over. Looking at the commits, it looks like the only changes were to bump up Google closure lib and to use UTF 8 for encoding. So, my guess would be that the new closure lib has a different behavior.
I've also pushed out a new version that works against the latest closure library, so that might help.
The new version works fine, thanks!
I've used version 0.2.7 for now which worked well. When switching to 0.2.8 it again stops creating minified packages as reported in #6 . The configuration is also the same.