h5bp / ant-build-script

Ant build script intended for use with HTML5 Boilerplate. You may find something useful here, but this project is archived.
MIT License
986 stars 203 forks source link

Concatenation after minifying and ADVANCED_OPTIMIZATIONS #162

Open bungle opened 11 years ago

bungle commented 11 years ago

If I understand correctly, this ANT Build task does js-minification in this order:

  1. minifies every js file
  2. concatenates minified js files

This is really problematic if you want to use Closure Compiler's ADVANCED_OPTIMIZATIONS. The order should be reversed:

  1. concatenates js files
  2. minifies the concatenated file

Or have I understood something wrong?

roblarsen commented 11 years ago

You're not missing anything. We minify everything first in order to allow people to minify files that will not be concatenated. it would be easy to swap the order, but it would be hairy to do it for the larger project, I think. I'd have to look at it.

bungle commented 11 years ago

I think you got it, but in other words the problem is that, say I have this:

<!-- //-beg- concat_js -->
Lots of JS-files here (that are calling each other,
but Closure Compiler does not know it because
everything is minified separately).
<!-- //-end- concat_js -->

It is really important to first concate everything between those tags, and after that minify. Otherwise ADVANCED_OPTIMIZATIONS is useless. This is the only place where you should concatenate first, others are fine as is.

roblarsen commented 11 years ago

Yes, I see your problem clearly. I was just pointing out why the script is the way it is. I don't have an answer off the top of my head as to how I would be able to reconfigure it in order to solve your problem while retaining the existing ease of use. I'd be happy to be able to solve your problem as long as I don't add any further complexity to the set up.

bungle commented 11 years ago

I see how this can add a little bit complexity, i.e. should we then also have separate options for minifying process (i.e. ADVANCED_OPTIOMIZATIONS for concatenated js-file, and SIMPLE_OPTIMIZATIONS for others).

roblarsen commented 11 years ago

I wasn't even thinking about that, but yes, that would open up further complexity. That would be a nice feature to add, actually.