nizarmah / auto-minify

Minifies JS and CSS files in GitHub workflows.
GNU General Public License v3.0
48 stars 18 forks source link

Unexpected token `const` #5

Closed C0pyR1ght closed 4 years ago

C0pyR1ght commented 4 years ago

Minifaction process fails with Unexpected token: keyword «const» if const is used in a file that is should be minified.

Example:

const url = "https://example.de";
nizarmah commented 4 years ago

Hello ( : So, yeah I believe the problem is because of uglifyjs, since I am using it to minify the file.

UglifyJS does not support es6. const is an es6 declaration, so it throws an error. ChrisR on StackOverflow

No worries though, I'll find a different package to use instead of uglifyjs. If you have any recommendations for annpm package that minifies JS files, please let me know.

You can solve the issue temporarily using var instead of const. But I promise you won't need to, I'll fix the issue today ( :

Edit:

I will be using babel-minify instead.

nizarmah commented 4 years ago

I also tested it in Auto-Minify-Test/issues#5

Here's a screenshot of the commits ( : image

Kindly let me know if there is anything else you'd want me to fix or add :D

By the way, I have been thinking of making it possible for users to pass their own "options" to the babel-minify and the clean-css commands being run. Let me know if that is something you are interested in so I work on adding it. If it isn't, so I don't waste time on it and work on something else.

nizarmah commented 4 years ago

Released v1.6 with ES6+ Support on the Marketplace ( : Just update the version you are currently using, and kindly let me know if you run into any new issues or if you have any recommendations!

Thanks a lot for all the contributions you have been doing. :heart:

C0pyR1ght commented 4 years ago

great, thanks for your quick fix