How to integrate uglify-es in grunt?
Asked Answered
M

2

18

I'm using gruntjs (which uses uglifyjs) to build my Angularjs app. But uglifyjs still does not support es6, so in corresponding GitHub issue i found this. So now there is uglify-es, which seemingly supports es6. But I'm not sure how to integrate it with grunt. Now i have module "grunt-contrib-uglify", which has a dependency uglifyjs, which is now used. How can i make grunt use uglify-es instead?

Masterstroke answered 30/6, 2017 at 13:58 Comment(0)
M
18

2023 UPD: this answer may be outdated, according to some comments. Didn't have time to check

I've achived this by installing the harmony branch of grunt-contrib-uglify, which supports es6:

npm install git://github.com/gruntjs/grunt-contrib-uglify.git#harmony --save-dev
Masterstroke answered 3/7, 2017 at 13:45 Comment(5)
Is this still the way to use for es6. I tried installing the above module and got a Permission denied on /var/root/.npm/_cacache/tmp/git-clone-5257398a npm ERR! /private/var/root/.npm/_cacache/tmp/git-clone-5257398a/.git I changed the permission to 777 for /var/root/.npm/_cacache/tmp/ but still end up with the errorNoontime
@jitenshah, do you have an error when just installing grunt-contrib-uglify, not specific branch? npm install grunt-contrib-uglify --save-devMasterstroke
No. I was able to install it easily. Even though I was in # prompt --> I ran your command with sudo like : sudo npm install git://github.com/gruntjs/grunt-contrib-uglify.git#harmony --save-dev and I was able to get the work done.Noontime
This answer saved my day.Helix
its locked and cant be installedThread
K
15

The ECMAScript version has finally been released. You can now get the same result with the official version (it's no longer needed to pick it from GitHub)

npm install grunt-contrib-uglify-es --save-dev

https://www.npmjs.com/package/grunt-contrib-uglify-es

Killough answered 16/2, 2018 at 7:52 Comment(4)
Thank you for sharing this :)Meyerbeer
Though the accepted answer solves the problem, this is the better and stable one than the accepted one, possibly because it is the more up-to-date solution.Hatchel
It's weird that it says 'This packed has been deprecated' but thx.Cenotaph
because it is deprecated, it doesnt work for meThread

© 2022 - 2024 — McMap. All rights reserved.