0
votes

During gulp-uglify task, SSI (server side includes) declarations are removed, maybe because uglify() removes invalid blocks of non-javascript code.

i.e.:

mymodule-source.js

"use strict";
<!--# include file="/ssi/config.js" -->
window.mymodule = function(mymodule) {};

After uglify() call on gulp pipe, it compress file to the following:

mymodule-minified.js

"use strict";window.mymodule=function(e){};

Expected result for app health, is the following result:

mymodule-expected.js

"use strict";<!--# include file="/ssi/config.js" -->window.mymodule=function(e){};

There is some kind of filter to declare to avoid SSI declarations being purged from final minified/uglified file?

By example, some kind of filter over regex ]+>

1

1 Answers

1
votes

I have the same question.I noticed that uglifyJs has --comment parameter. Preserve copyright comments in the output. By default this works like Google Closure, keeping JSDoc-style comments that contain "@license" or "@preserve". You can optionally pass one of the following arguments to this flag: - "all" to keep all comments - a valid JS RegExp like /foo/ or /^!/ to keep only matching comments. Note that currently not all comments can be kept when compression is on, because of dead code removal or cascading statements into sequences.

But I don't know how to use --comment in gulp task.