eriwen / gradle-js-plugin

Gradle plugin for working with JS
http://eriwen.github.io/gradle-js-plugin
Apache License 2.0
382 stars 113 forks source link

Minify multiple JS files without combining #158

Open alireza19330 opened 6 years ago

alireza19330 commented 6 years ago

I want to minify multiple JS files in a directory without combining them together. for example I have these files in my directory: first.js, second.js, third.js .... and I want to have the minified version of them on the same directory and the same files. Sorry, I'm not too familiar with Gradle and groovy syntax.

Is there any way to do so? I want to do something like that:

apply plugin: 'com.eriwen.gradle.js'
task MinifyJsFiles(type: com.eriwen.gradle.js.tasks.MinifyJsTask) {
    source = DIR_TO_ALL_JS_FILES
    dest = DIR_TO_PERSIST_OR_OVERRIDE_JS_FILES
    closure.warningLevel = 'QUIET'
}

Right now I handled that by defining several Gradle task for each minifying!

alireza19330 commented 6 years ago

I found a good way here: https://stackoverflow.com/a/40230421/826008 I think it's a good idea to merge this piece of code to the MinifyJS plugin

rkrisztian commented 5 years ago

That is not a good way at all, considering that:

It would be better to be able to tell what I want to minify and how using a closure mapper, for example...

Edit (2019-10-24): Also consider an incremental task (for fine-grained up-to-date checks) + the Worker API (for parallel execution). They aren't really difficult if you follow the official user guides.

ChrisAcrobat commented 5 years ago

Have there been any progress on this? Would it also be possible to obfuscate them separately? I have separate roots in my project. It is functional to merge the files, but it is not optimal since the file gets bigger again with code that is never going to be used.

ChrisAcrobat commented 5 years ago

I saw this from @eriwen: https://stackoverflow.com/a/34187137 Have this been implemented yet, or do I still need to create a local version? I will experiment with this later.

jvs64893 commented 4 years ago

@ChrisAcrobat Did you get this to work? I can't seem to get this working, even by following the exact steps.

@eriwen Any chance to add this function "officially" to the plugin?

ChrisAcrobat commented 4 years ago

Yes. I think I needed to do some changes to make it work for my project, but yes. I think it was remove ".min" and put in a directory instead.