Skip to content
This repository has been archived by the owner on Jul 17, 2022. It is now read-only.

Minify multiple JS files without combining #158

Open
alireza19330 opened this issue Mar 28, 2018 · 6 comments
Open

Minify multiple JS files without combining #158

alireza19330 opened this issue Mar 28, 2018 · 6 comments

Comments

@alireza19330
Copy link

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
Copy link
Author

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
Copy link

rkrisztian commented Jul 19, 2019

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

  • Gradle 4 already deprecates Task.execute, and Gradle 5 even removes it. (And this plugin hasn't been updated since late 2017.)
  • You may end up having hundreds of tasks, this may look really hard to read in the logs. And if you create these tasks in configuration time (which one of the SO answers suggests (for cleaner design), not the one linked above of course), your build script may become too slow.

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
Copy link

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
Copy link

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
Copy link

@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
Copy link

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.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants