gpt4 book ai didi

javascript - Babili 缩小但不转译

转载 作者:太空宇宙 更新时间:2023-11-04 00:22:16 26 4
gpt4 key购买 nike

我被 babili 困住了.

我需要转译,然后缩小用ES6编写的javascript。所以我使用以下方法安装了该软件包:

npm install babili --save-dev

并制作了包含预设的.babelrc文件:

{"presets": ["es2015"]}

现在我尝试了以下命令

./node_modules/.bin/babili public/js/rt.socket.js --out-file public/test.min.js

它确实给出了缩小但不转译。这可能是什么原因?`

最佳答案

Babili 不使用.babelrc 。根据 README :

Note that, because the babili command uses the default preset with no-babelrc, you cannot set any non-default options in the preset's plugins with this command. To do this, you can use the babel command with the options set in a .babelrc. See the preset docs for more information on how to do this.

解决方案是使用 Babel 和 babel-preset-babili预设,如 Babel preset 中所述自述文件部分(假设您已经安装了 Babel):

Install

npm install babel-preset-babili --save-dev

Usage

You'll most likely want to use it only in the production environment. Check out the env docs for more help.

Options specific to a certain environment are merged into and overwrite non-env specific options.

.babelrc:

{
"presets": ["es2015"],
"env": {
"production": {
"presets": ["babili"]
}
}
}

然后你需要设置环境变量,它可能类似于 BABEL_ENV=production npm run build

关于javascript - Babili 缩小但不转译,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44142480/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com