Angular-cli 8 - 是否可以仅在 es2015 上构建?

问题描述:

在 angular-cli 的第 8 版中,构建完成了 2 次.一个在 es5,一个在 es2015.

In version 8 of angular-cli, the build is done 2x. One in es5 and one in es2015.

是否可以只在 es2015 上构建?

Is it possible to build only on es2015?

将target改成es5,只在es5中完成..但是我还没有找到只在es2015中做到的方法.

Changing the target to es5, it is done only in es5 .. But I have not found a way to do it only in es2015.

如果您相应地更新了browserslist(.browserlistrc-file 或 browserlist-Array in package.json) 并且只添加支持 ES2015 的浏览器,只需要一个构建已创建.

If you update your browserslist accordingly (.browserlistrc-file or browserlist-Array in package.json) and only add browsers which are capable of ES2015, only one build should be created.

例如,当使用

"browserslist": [
  "> 5%"
]

对于 es5es2015,我只得到一个版本而不是两个版本.(好吧,公平地说,只有 chrome 以 > 5% 进入列表...)

I only get one build instead of two builds for es5 and es2015. (Okay, to be fair, only chrome makes it into the list with > 5%...)

(您还可以使用 npx browserslist 查看当前项目设置支持的浏览器列表.另外,请参阅 "差分加载"-部分在这里有详细解释.)

(You can also check with npx browserslist for a list of browsers that would currently be supported with your project setup. Also, see the "Differential Loading"-part here for a detailed explanation.)