From 13b5bbbc2c03cff52796041b0c1f46c426f33c3a Mon Sep 17 00:00:00 2001 From: Jure Grabnar Date: Tue, 2 Jul 2019 13:55:22 +0200 Subject: [PATCH] Rename .babelrc and .postcssrc.yml to babel.config.js postcss.config.js --- .babelrc | 26 ----------------- .postcssrc.yml | 3 -- babel.config.js | 72 +++++++++++++++++++++++++++++++++++++++++++++++ postcss.config.js | 12 ++++++++ 4 files changed, 84 insertions(+), 29 deletions(-) delete mode 100644 .babelrc delete mode 100644 .postcssrc.yml create mode 100644 babel.config.js create mode 100644 postcss.config.js diff --git a/.babelrc b/.babelrc deleted file mode 100644 index 81911fe0c..000000000 --- a/.babelrc +++ /dev/null @@ -1,26 +0,0 @@ -{ - "presets": [ - [ - "@babel/preset-env", - { - "modules": false, - "targets": { - "browsers": "> 1%", - "uglify": true - }, - "useBuiltIns": true - } - ], - "@babel/preset-flow" - ], - "plugins": [ - "@babel/plugin-syntax-dynamic-import", - "@babel/plugin-proposal-object-rest-spread", - [ - "@babel/plugin-proposal-class-properties", - { - "spec": true - } - ] - ] -} diff --git a/.postcssrc.yml b/.postcssrc.yml deleted file mode 100644 index 150dac3c6..000000000 --- a/.postcssrc.yml +++ /dev/null @@ -1,3 +0,0 @@ -plugins: - postcss-import: {} - postcss-cssnext: {} diff --git a/babel.config.js b/babel.config.js new file mode 100644 index 000000000..12f98da5a --- /dev/null +++ b/babel.config.js @@ -0,0 +1,72 @@ +module.exports = function(api) { + var validEnv = ['development', 'test', 'production'] + var currentEnv = api.env() + var isDevelopmentEnv = api.env('development') + var isProductionEnv = api.env('production') + var isTestEnv = api.env('test') + + if (!validEnv.includes(currentEnv)) { + throw new Error( + 'Please specify a valid `NODE_ENV` or ' + + '`BABEL_ENV` environment variables. Valid values are "development", ' + + '"test", and "production". Instead, received: ' + + JSON.stringify(currentEnv) + + '.' + ) + } + + return { + presets: [ + isTestEnv && [ + '@babel/preset-env', + { + targets: { + node: 'current' + } + } + ], + (isProductionEnv || isDevelopmentEnv) && [ + '@babel/preset-env', + { + forceAllTransforms: true, + useBuiltIns: 'entry', + corejs: 3, + modules: false, + exclude: ['transform-typeof-symbol'] + } + ] + ].filter(Boolean), + plugins: [ + 'babel-plugin-macros', + '@babel/plugin-syntax-dynamic-import', + isTestEnv && 'babel-plugin-dynamic-import-node', + '@babel/plugin-transform-destructuring', + [ + '@babel/plugin-proposal-class-properties', + { + loose: true + } + ], + [ + '@babel/plugin-proposal-object-rest-spread', + { + useBuiltIns: true + } + ], + [ + '@babel/plugin-transform-runtime', + { + helpers: false, + regenerator: true, + corejs: false + } + ], + [ + '@babel/plugin-transform-regenerator', + { + async: false + } + ] + ].filter(Boolean) + } +} diff --git a/postcss.config.js b/postcss.config.js new file mode 100644 index 000000000..aa5998a80 --- /dev/null +++ b/postcss.config.js @@ -0,0 +1,12 @@ +module.exports = { + plugins: [ + require('postcss-import'), + require('postcss-flexbugs-fixes'), + require('postcss-preset-env')({ + autoprefixer: { + flexbox: 'no-2009' + }, + stage: 3 + }) + ] +}