yogthos / asset-minifier Goto Github PK
View Code? Open in Web Editor NEWa library to minify CSS/Js resources
License: Eclipse Public License 1.0
a library to minify CSS/Js resources
License: Eclipse Public License 1.0
there is a minify task in boot-cljsjs that uses minify-js
. Being able to set the closure compiler option for "language-in" to ECMASCRIPT5 will help us prevent "trailing comma" errors when minifying some cljsjs-packages that are auto-built.
I can create the PR; just let me know if you have thoughts on it. thanks
I need to transpile a package from ES6 to ES5 in cljsjs/packages, which uses asset-minifier.core/minify-js
to do minifications. Currently this is not possible as LANGUAGE_OUT
arg cannot be set, and hence this error:
ES6 is only supported for transpilation to a lower ECMAScript version. Set --language_out to ES3, ES5, or ES5_STRICT.
Any ideas or thought, or shall I just create a PR? I'd gladly do that BTW.
Cheers!
I'm using lein-asset-minifier and ran into a problem:
minifying assets...
java.io.FileNotFoundException: resources/public/js/libs.js (No such file or directory)
at java.io.FileOutputStream.open (FileOutputStream.java:-2)
java.io.FileOutputStream.<init> (FileOutputStream.java:221)
clojure.java.io/fn (io.clj:230)
clojure.java.io$fn__8641$G__8604__8648.invoke (io.clj:69)
clojure.java.io/fn (io.clj:263)
clojure.java.io$fn__8641$G__8604__8648.invoke (io.clj:69)
clojure.java.io/fn (io.clj:166)
clojure.java.io$fn__8654$G__8608__8661.invoke (io.clj:69)
clojure.java.io$writer.doInvoke (io.clj:119)
clojure.lang.RestFn.invoke (RestFn.java:410)
asset_minifier.core$minify_js.doInvoke (core.clj:112)
clojure.lang.RestFn.invoke (RestFn.java:442)
asset_minifier.core$minify$iter__1060__1064$fn__1065.invoke (core.clj:127)
clojure.lang.LazySeq.sval (LazySeq.java:40)
clojure.lang.LazySeq.seq (LazySeq.java:49)
clojure.lang.RT.seq (RT.java:484)
clojure.core$seq.invoke (core.clj:133)
clojure.core.protocols$seq_reduce.invoke (protocols.clj:30)
clojure.core.protocols/fn (protocols.clj:54)
clojure.core.protocols$fn__6031$G__6026__6044.invoke (protocols.clj:13)
clojure.core$reduce.invoke (core.clj:6289)
clojure.core$into.invoke (core.clj:6341)
asset_minifier.core$minify.doInvoke (core.clj:124)
clojure.lang.RestFn.invoke (RestFn.java:423)
leiningen.minify_assets$minify.invoke (minify_assets.clj:42)
leiningen.minify_assets$minify_assets.doInvoke (minify_assets.clj:99)
clojure.lang.RestFn.invoke (RestFn.java:423)
clojure.lang.Var.invoke (Var.java:383)
clojure.lang.AFn.applyToHelper (AFn.java:156)
clojure.lang.Var.applyTo (Var.java:700)
clojure.core$apply.invoke (core.clj:626)
leiningen.core.main$partial_task$fn__6071.doInvoke (main.clj:253)
clojure.lang.RestFn.applyTo (RestFn.java:139)
clojure.lang.AFunction$1.doInvoke (AFunction.java:29)
clojure.lang.RestFn.applyTo (RestFn.java:137)
clojure.core$apply.invoke (core.clj:626)
leiningen.core.main$apply_task.invoke (main.clj:303)
leiningen.core.main$resolve_and_apply.invoke (main.clj:309)
leiningen.do$do.doInvoke (do.clj:40)
clojure.lang.RestFn.invoke (RestFn.java:516)
clojure.lang.Var.invoke (Var.java:409)
clojure.lang.AFn.applyToHelper (AFn.java:178)
clojure.lang.Var.applyTo (Var.java:700)
clojure.core$apply.invoke (core.clj:626)
leiningen.core.main$partial_task$fn__6071.doInvoke (main.clj:253)
clojure.lang.RestFn.invoke (RestFn.java:410)
clojure.lang.AFn.applyToHelper (AFn.java:154)
clojure.lang.RestFn.applyTo (RestFn.java:132)
clojure.lang.AFunction$1.doInvoke (AFunction.java:29)
clojure.lang.RestFn.applyTo (RestFn.java:137)
clojure.core$apply.invoke (core.clj:626)
leiningen.core.main$apply_task.invoke (main.clj:303)
leiningen.core.main$resolve_and_apply.invoke (main.clj:309)
leiningen.core.main$_main$fn__6136.invoke (main.clj:377)
leiningen.core.main$_main.doInvoke (main.clj:366)
clojure.lang.RestFn.invoke (RestFn.java:408)
clojure.lang.Var.invoke (Var.java:379)
clojure.lang.AFn.applyToHelper (AFn.java:154)
clojure.lang.Var.applyTo (Var.java:700)
clojure.core$apply.invoke (core.clj:624)
clojure.main$main_opt.invoke (main.clj:315)
clojure.main$main.doInvoke (main.clj:420)
clojure.lang.RestFn.invoke (RestFn.java:436)
clojure.lang.Var.invoke (Var.java:388)
clojure.lang.AFn.applyToHelper (AFn.java:160)
clojure.lang.Var.applyTo (Var.java:700)
clojure.main.main (main.java:37)
The js
directory does not exist inside resources/public
(because lein clean
removed it). Could you automatically create the parent directories with (io/make-parents dest-file)
?
There could be a way of create multiples targets with the same source file, so i will not have a big file with all js, and i only need to import in my html the file that i want. It will only minify the file, not group all files in one.
Something like this example:
:minify-assets [[:js {
:source ["source/"]
:target "target/",
:pattern "*.min.js"}]]
from:
source
├── login.js
└── home.js
to
target
├── login.min.js
└── home.min.js
What you think of it?
In addition to CSS and JS, HTML can also be minified to reduce the size of assets that need to be sent over the wire.
There is an existent library for the JVM that does that well: htmlcompressor. Example Clojure use of this can be found here.
Would you accept a PR for this? Any additional thoughts?
Right now if source
is a directory with subdirectories, the subdirectory structure will not be preserved in target
. Would it make sense to preserve any subdirectory structure in the target
directory? The current behavior runs the risk of files in subdirectories overwriting identically-named files in a parent directory (in the target
directory).
Otherwise, it would be nice to be able to disallow this recursive behavior, giving the user the chance to handle subdirectories with multiple calls to minify
.
I am actually having this problem with the lein-asset-minifier project, but I'm guessing this is the appropriate place for the issue. If you you think either of these should be implemented but don't have the time to do it yourself, I'd be happy to help.
I am getting this exception when using minify-js:
java.lang.String cannot be cast to java.nio.charset.Charset
on a side note: why use such an old closure compiler?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.