@4c/babel-preset 中文文档教程
@4c/babel-preset
一个可配置的、包含电池的、用于库和网络应用程序的 babel 预设。
包括以下预设和插件:
Install
yarn add @4c/babel-preset -D
Configure
没有选项:
{
"presets": ["@4c"]
}
有选项;
{
"presets": [
[
"@4c",
{
"target": "web-app",
"modules": false,
"intl": { "prefix" "@mylib" },
}
]
]
}
Options
除了下面的选项,所有的 preset-env 都是 当默认值不够时,接受被覆盖。 默认预设 选择一组为所选 target
量身定制的已知安全组合。
target
<代码>'网络' | '网络应用程序' | 'node',默认为 'web'
整体构建环境目标。 用于设置一些智能预设以及 配置 preset-env
目标。
node
targets
set to node10
in production andcurrent
in developmentmodules
set tocommonjs
intl
is disabled
web
targets
uses the browserlist config is (determined by .browserslistrc, etc) if available or defaults to['ie >= 11', 'last 2 Edge versions', 'last 4 Chrome versions', 'last 4 Firefox versions', 'last 2 Safari versions'];
web-app
- uses the same targets as
web
- defaults
modules
tofalse
- defaults
runtime
totrue
development
boolean
, 默认为false
使用更加开发友好的一组 targets
以及切换 react 开发插件(参见 . 当 true
节点目标的 current
版本和 esmodules
用于网络目标。 您可以在此处阅读更多内容。
modules
"commonjs' | false
,默认为 false
除非 target
是 'web-app'
和 'commonjs'
otherwise
preset-env 模块选项。控制输出模块格式
runtime
打开 babel 运行时转换。
intl
boolean | { prefix: string, messagesDir: string }
配置 react-intl
babel 插件以提取和输出本地化字符串 以包名称为前缀或提供 prefix
@4c/babel-preset
A configurable, batteries included, babel preset for libraries and web apps.
Includes the following presets and plugins:
Install
yarn add @4c/babel-preset -D
Configure
Without options:
{
"presets": ["@4c"]
}
With options;
{
"presets": [
[
"@4c",
{
"target": "web-app",
"modules": false,
"intl": { "prefix" "@mylib" },
}
]
]
}
Options
In addition to the options below, all preset-env are accepted to be overridden when the defaults aren't sufficient. By default the preset picks a set of known safe combinations tailored to the chosen target
.
target
'web' | 'web-app' | 'node'
, defaults to 'web'
The overall build environment target. Used to set some smart presets as well as configure the preset-env
targets.
node
targets
set to node10
in production andcurrent
in developmentmodules
set tocommonjs
intl
is disabled
web
targets
uses the browserlist config is (determined by .browserslistrc, etc) if available or defaults to['ie >= 11', 'last 2 Edge versions', 'last 4 Chrome versions', 'last 4 Firefox versions', 'last 2 Safari versions'];
web-app
- uses the same targets as
web
- defaults
modules
tofalse
- defaults
runtime
totrue
development
boolean
, defaults to false
Uses a more development friendly set of targets
as well as toggles development plugins for react (see. When true
the current
version of node for node targets and esmodules
for web targets. You can read more here.
modules
"commonjs' | false
, defaults to false
except when target
is 'web-app'
and 'commonjs'
otherwise
The preset-env modules option. controls the output module format
runtime
Turns on the babel runtime transform.
intl
boolean | { prefix: string, messagesDir: string }
Configures the react-intl
babel plugin to extract and output localized strings prefixed by the package name or provided prefix