nizarmah / auto-minify

Minifies JS and CSS files in GitHub workflows.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Unexpected token `const`

C0pyR1ght opened this issue · comments

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";
commented

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.

commented

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.

commented

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. ❤️

great, thanks for your quick fix