简体   繁体   中英

Minify ES6 JS Code in Meteor

In my Meteor site, I recently discovered that the Javascript was not minified in production. A quick look into the plugins revealed, that the standard-minifiers-js package was missing. Once I added this and tried it via meteor --production , I quickly discovered, that uglify-js (which is used in standard-minifiers-js ) does not support ES6. As the whole project is written using ES6, this can't be changed. There is, however, a package called uglify-es which should be able to minify ES6, but I don't know how to get Meteor's standard minifiers to use it (a solution without manually replacing packages, which might be overwritten and has to be done on each server the project is installed would be best)

TL;DR: How can I get standard-minifiers-js from Meteor to use uglify-es instead of uglify-js ?

Add the ecmascript package as well as standard-minifiers-js .

ecmascript will transpile your ES6 with babel before minification

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM