Package to uglify / minify multiple files

I want to uglify or minify all files in a folder and its subfolders to files with the same name in a new folder and its subfolders. So just create a copy of a folder where all the files have, where possible, been minified.

For example, minifying

creates minified files

I can’t see a way to do this with any of the ATOM packages. But I expect that ‘batch minifying’ would be a common request, e.g. to deliver a large project where all code has been minified.

Any of the command line tools for minifying can be used through a package such as process-palette.

I suppose that might work, since it appears that a short script for Grunt’s uglify will uglify all files within a directory . But it means I’ll have to get grunt up and running and check the script is right and be able to run it properly in process-palette. Seems a lot of overhead that is unlikely to work out of the box. And I’m losing much of the benefit of working in Atom.
I’m still hoping to find out whether one of the many Atom packages for uglifying and minifying allows one to minify all files in a directory to a new directory.

If anyone told you that the benefit of working in Atom was to have everything functional out of the box, they lied to you and you should never trust them with money. The benefit of working with Atom is that you can make it do literally anything you want it to. In many cases, that thing you want to do is something someone else has wanted to do badly enough that they wrote a package for it, but if it’s not, which in this case might have to do with the fact that there are great build pipeline tools that are commonly used, then you have to either do the work or convince someone else to do the work.

(Hint: If you browse through some of the threads on this forum, you’ll find that it’s not hard to convince me to give you the answers and help you write your code. You just have to not be averse to learning new things. I’m fine with people who want out-of-the-box IDEs abandoning Atom, because it’s not for that sort of person. It’s for the sort of person who wants to tinker and make things work just the way they want them to.)

Have you looked at all of them? I did and don’t see any documentation indicating that this is the case. So either you can hope for something that doesn’t appear to exist, or you can accept an answer that will solve your problem in no time.

All of those packages do the same thing: run UglifyJS on a file. If you go look at the documentation, you’ll see that UglifyJS only operates on one file at a time. Without a task-runner program or a batch file, it’s impossible to run it on more than one file at once. If you’re fine running it on one file at a time, you could install UglifyJS with npm install -g uglify-js (you need Node installed first, but if you’re doing a lot of web coding work you will want Node installed anyway) and set up a process-palette command that saves the file and then runs UglifyJS on it, but it will require that you only use Atom to make changes to your files. If you set up a task-runner script, you can run it from anywhere, on anybody’s computer as long as they have Node installed, and it will process your entire folder so that nothing is left out.

To me, the benefit of Atom so far has been just that it is a really good text editor that doubles as a development environment. And that the packages are generally great, which is similar to what you said about it being able to do anything you want it to. But I personally am more focused on the application I’m developing than on being a developer, which is why I’m asking naïve newbie questions.

Agreed, and I asked the question because I thought this might be the type of thing that would be in a package,.

I wouldn’t say that I’ve done a brute force inventory and assessment, but I tried about four with the most downloads and looked at documentation for others, and wasn’t seeing it. But again, it seemed like such an obvious thing to do and I’m a newbie, which is why I thought I might be overlooking something.

Anyway, (see robots4life comment at the end) looks like the best option I’ve found. But I haven’t used Grunt before so it will take some effort. Plus, I can’t tell if this will allow me to maintain the subdirectories for the minified version, or just put everything in a single ‘flat’ new directory. And it looks like its only for minifying js, not css or html as well.

I’ll proceed with the Grunt approach for now. But I appreciate and welcome all the advice.

FYI, I think the process to build your code should be editor independent. If Grunt does what you need, it will be far more portable than anything specific to Atom (and Atom can still execute build scripts).

1 Like