From ae7639c1d4281736ce645d1c0d7fe8b2869b7d9e Mon Sep 17 00:00:00 2001 From: Pig Fang Date: Mon, 24 Sep 2018 10:36:08 +0800 Subject: [PATCH] Update Babel config --- .babelrc | 29 ----------------------------- .browserslistrc | 2 ++ babel.config.js | 37 +++++++++++++++++++++++++++++++++++++ webpack.config.js | 9 +-------- 4 files changed, 40 insertions(+), 37 deletions(-) delete mode 100644 .babelrc create mode 100644 babel.config.js diff --git a/.babelrc b/.babelrc deleted file mode 100644 index 55ea38e2..00000000 --- a/.babelrc +++ /dev/null @@ -1,29 +0,0 @@ -{ - "presets": [ - ["@babel/preset-env", { - "modules": false, - "useBuiltIns": false, - "loose": true - }] - ], - "plugins": [ - "@babel/plugin-syntax-dynamic-import", - ["@babel/plugin-transform-runtime", { - "helpers": true, - "regenerator": true - }] - ], - "env": { - "test": { - "presets": [ - ["@babel/preset-env", { - "targets": { "node": "current" }, - "ignoreBrowserslistConfig": true - }] - ], - "plugins": [ - "babel-plugin-dynamic-import-node" - ] - } - } -} diff --git a/.browserslistrc b/.browserslistrc index 53eba312..572ea7ba 100644 --- a/.browserslistrc +++ b/.browserslistrc @@ -1,2 +1,4 @@ > 1% +not dead not ie 11 +Chrome > 52 diff --git a/babel.config.js b/babel.config.js new file mode 100644 index 00000000..35917236 --- /dev/null +++ b/babel.config.js @@ -0,0 +1,37 @@ +module.exports = api => ({ + production: { + presets: [ + ['@babel/preset-env', { + useBuiltIns: false, + loose: true + }] + ], + plugins: [ + '@babel/plugin-syntax-dynamic-import', + ['@babel/plugin-transform-runtime', { + helpers: true, + regenerator: true + }] + ] + }, + development: { + presets: [ + ['@babel/preset-env', { + targets: { esmodules: true } + }] + ], + plugins: [ + '@babel/plugin-syntax-dynamic-import', + ] + }, + test: { + presets: [ + ['@babel/preset-env', { + targets: { node: 'current' } + }] + ], + plugins: [ + 'babel-plugin-dynamic-import-node' + ] + }, +})[api.env()]; diff --git a/webpack.config.js b/webpack.config.js index c620787f..591bee20 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -42,14 +42,7 @@ const config = { exclude: /node_modules/, use: [ 'cache-loader', - { - loader: 'babel-loader', - options: { - plugins: [ - '@babel/plugin-transform-async-to-generator' - ] - } - } + 'babel-loader' ] }, {