Is there an uglifying/minifying library which allows to exclude indicated character sets?

88 Views Asked by At

I have to exclude non-javascript character sets like <%,<%-, <%= and %> character sets when I uglifying / minifying javascript codes. (Just these characters)

For example the below codes should be transform to its below codes after uglified/minified process;

raw codes;

 <% if (!user.admin) { %>
    var a=1;
    console.log(a);
 <% } %>     

minified codes;

 <% if (!user.admin) { %>var a=1;console.log(a);<% } %>  
1

There are 1 best solutions below

1
On

Use https://github.com/yeoman/grunt-usemin

Take a look at specifically https://github.com/yeoman/grunt-usemin#blockreplacements

Define your own block and replace it with whatever suits you.