From 0bb2573387a61a0e4da5d4f9a6545a7a0224ad5e Mon Sep 17 00:00:00 2001 From: slowbackspace Date: Mon, 4 Feb 2019 17:17:20 +0100 Subject: [PATCH] fix babel config --- babel.config.js | 91 +++++++++++++++++++++++++------------------------ 1 file changed, 46 insertions(+), 45 deletions(-) diff --git a/babel.config.js b/babel.config.js index 5556ac0f..63b60eee 100644 --- a/babel.config.js +++ b/babel.config.js @@ -1,50 +1,51 @@ module.exports = (api) => { - api.cache(true); + // api.cache.forever(); + + const presets = [ + [ + '@babel/preset-env', + { + useBuiltIns: 'entry', + loose: true, + }, + ], + '@babel/preset-react', + '@babel/preset-flow', + ]; + + const plugins = [ + 'react-hot-loader/babel', + '@babel/plugin-transform-flow-strip-types', + '@babel/plugin-proposal-class-properties', + '@babel/plugin-proposal-object-rest-spread', + [ + '@babel/plugin-transform-runtime', + { + regenerator: true, + }, + ], + [ + 'module-resolver', + { + root: [ + './src', + ], + alias: { + public: [ + './public', + ], + }, + }, + ], + 'babel-plugin-styled-components', + ]; + + if (api.env('test')) { + presets.push('jest'); + } return { - presets: [ - [ - '@babel/preset-env', - { - useBuiltIns: 'entry', - loose: true, - }, - ], - '@babel/preset-react', - '@babel/preset-flow', - ], - plugins: [ - 'react-hot-loader/babel', - '@babel/plugin-transform-flow-strip-types', - '@babel/plugin-proposal-class-properties', - '@babel/plugin-proposal-object-rest-spread', - [ - '@babel/plugin-transform-runtime', - { - regenerator: true, - }, - ], - [ - 'module-resolver', - { - root: [ - './src', - ], - alias: { - public: [ - './public', - ], - }, - }, - ], - 'babel-plugin-styled-components', - ], - env: { - test: { - presets: [ - 'jest', - ], - }, - }, + presets, + plugins, }; }; \ No newline at end of file