Use static Babel config file

This commit is contained in:
Pig Fang 2019-11-26 11:10:05 +08:00
parent 9871e2e484
commit a43e8036c5
2 changed files with 55 additions and 43 deletions

View File

@ -1,43 +0,0 @@
module.exports = api => ({
production: {
presets: [
['@babel/preset-env', {
useBuiltIns: false,
loose: true,
}],
'@babel/preset-typescript',
],
plugins: [
'@babel/plugin-syntax-dynamic-import',
['@babel/plugin-transform-runtime', {
helpers: true,
regenerator: true,
}],
'@babel/plugin-proposal-optional-catch-binding',
],
},
development: {
presets: [
['@babel/preset-env', {
targets: { esmodules: true },
}],
'@babel/preset-typescript',
],
plugins: [
'@babel/plugin-syntax-dynamic-import',
'@babel/plugin-proposal-optional-catch-binding',
],
},
test: {
presets: [
['@babel/preset-env', {
targets: { node: 'current' },
}],
'@babel/preset-typescript',
],
plugins: [
'babel-plugin-dynamic-import-node',
'@babel/plugin-proposal-optional-catch-binding',
],
},
})[api.env()]

55
babel.config.json Normal file
View File

@ -0,0 +1,55 @@
{
"presets": [
"@babel/preset-typescript"
],
"plugins": [],
"env": {
"production": {
"presets": [
[
"@babel/preset-env",
{
"useBuiltIns": false,
"loose": true
}
]
],
"plugins": [
[
"@babel/plugin-transform-runtime",
{
"helpers": true,
"regenerator": true
}
]
]
},
"development": {
"presets": [
[
"@babel/preset-env",
{
"targets": {
"esmodules": true
}
}
]
]
},
"test": {
"presets": [
[
"@babel/preset-env",
{
"targets": {
"node": "current"
}
}
]
],
"plugins": [
"babel-plugin-dynamic-import-node"
]
}
}
}