Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Possible improvements: save-license, do not uglify framework (, images) #38

Open
luigi37 opened this issue Feb 25, 2018 · 2 comments
Open

Comments

@luigi37
Copy link

luigi37 commented Feb 25, 2018

I modified the script to KEEP the license at the beginning of my code and exclude frameworks like jquery as they might have issues.

In declarations:

var saveLicense = require('uglify-save-license');

then in "compress" function

switch (ext) {
case '.js':
  
console.log('?? js file ' + file);
 if (file.indexOf("jquery")<=-1) {
   console.log('--------------------uglifying js file ' + file);
    res = ngAnnotate(String(fs.readFileSync(file)), {
        add: true
    });
    
    result = UglifyJS.minify(res.src, {
            compress: {
                "drop_console": true
            }, 
            output: {
                comments: saveLicense
            },
            //fromString: true //removed because incompatible with uglify-js3
        });
    fs.writeFileSync(file, result.code, 'utf8'); // overwrite the original unminified file
}
  break;

I think those two things are quite useful.
I did not issue a pull request as the code (especially for skipping jquery) is quite poor...

Would be great if those two things could be implemented.

I found also code about image but I think those were yours original and for some reason got deleted?

Thanks

@rossmartin
Copy link
Owner

rossmartin commented Mar 3, 2018

Hey sorry it’s taken awhile to get to this. I’ll add the uglify-save-license package and have it available as an option.

Did you experience issues with uglify running against frameworks? I’ve never had any issues before.

If you need to exclude frameworks one easy way is to put them in their own folder and not have the hook configured to run against files in it, ex. www/lib/js

Thanks

@luigi37
Copy link
Author

luigi37 commented Mar 3, 2018

Hi Ross, no problem at all.
Thanks for save license
More than problem with Frameworks is problem with already minified frameworks...
So you suggest to exclude directories?
Thanks
Luigi

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants