Initial Comment Block

Sep 11, 2009 at 10:55 AM

Hi all,

 

Great project, this is exactly the sort of thing I needed.  (and after half a day of fiddling have got it set to work with a build action)

I have one query, as a requirement for the business I work for we need to keep the initial line(s) of comment block in the javascript files (so we can identify what version of the javascript(s) are in the mini-ed file.  I've started looking at the source code to see how possible this would be but was wondering if anyone else has had to do this before?

Would be a great addition to the core project if there was a switch that allowed the 1st comment block for each js file to be kept or chucked with the rest of the comments.

Coordinator
Sep 11, 2009 at 11:01 AM
Edited Sep 11, 2009 at 11:01 AM

Hi SkipIsHere - glad u've found this project and it actually helps you :)

Hmm.. ok .. i fully understand what you mean but nope - I'm not under the impression that anyone has done this.

If it's a comment, it will be stripped. So, the first three things that come to my mind are

1) tweak the code so a 'custom' tag of some sorts might be used and post build, the start tag / end tag thingies get string replaced to a proper comment tag.
2) have another file which merges with the output. this other file is the prepending comment text that is required.
3) add a setting to theconfig file which accepts a key/value piece of data :: key = filename, value = comments to put at the top.

none of these solutions are actually very 'maintainable' though - they do add extra complexity. I personally wouldn't want to add them to the public drop due to that factor.

I'm sure there's a better way to handle it.

I'm guessing the comment is some stock standard stuff like 'This code is the property of my boss so bugger off' or whatever.

Keep us posted please :)

Sep 15, 2009 at 4:39 PM

After reading some of the code I'd realised that there would have been no easy way to mod the code, I did try a 'grab the comment before minification' approach but then we discovered that the compressor does actually have what we need built into it.

 

Basically any comment block that has an ! at the start will be kept, such as

/*!
 * Bulit by Blah - version blah blah
*/

 

Hope this helps others out in the future, I;m sure I'll be back here posting again soon :)