diff options
Diffstat (limited to 'babel.config.js')
-rw-r--r-- | babel.config.js | 65 |
1 files changed, 65 insertions, 0 deletions
diff --git a/babel.config.js b/babel.config.js new file mode 100644 index 000000000..a506ad8ce --- /dev/null +++ b/babel.config.js @@ -0,0 +1,65 @@ +module.exports = (api) => { + const env = api.env(); + + const envOptions = { + debug: false, + loose: true, + modules: false, + }; + + const config = { + presets: [ + '@babel/react', + ['@babel/env', envOptions], + ], + plugins: [ + '@babel/syntax-dynamic-import', + ['@babel/proposal-object-rest-spread', { useBuiltIns: true }], + ['@babel/proposal-decorators', { legacy: true }], + '@babel/proposal-class-properties', + ['react-intl', { messagesDir: './build/messages' }], + 'preval', + ], + }; + + switch (env) { + case 'production': + envOptions.debug = false; + config.plugins.push(...[ + 'lodash', + [ + 'transform-react-remove-prop-types', + { + mode: 'remove', + removeImport: true, + additionalLibraries: [ + 'react-immutable-proptypes', + ], + }, + ], + '@babel/transform-react-inline-elements', + [ + '@babel/transform-runtime', + { + helpers: true, + regenerator: false, + useESModules: true, + }, + ], + ]); + break; + case 'development': + envOptions.debug = true; + config.plugins.push(...[ + '@babel/transform-react-jsx-source', + '@babel/transform-react-jsx-self', + ]); + break; + case 'test': + envOptions.modules = 'commonjs'; + break; + } + + return config; +}; + |