2019-04-02 15:41:28 +00:00
|
|
|
module.exports = api => {
|
2019-02-04 16:17:20 +00:00
|
|
|
// api.cache.forever();
|
2019-02-04 14:09:35 +00:00
|
|
|
|
2019-02-04 16:17:20 +00:00
|
|
|
const presets = [
|
|
|
|
[
|
|
|
|
'@babel/preset-env',
|
|
|
|
{
|
|
|
|
useBuiltIns: 'entry',
|
|
|
|
loose: true,
|
|
|
|
},
|
2019-02-04 14:09:35 +00:00
|
|
|
],
|
2019-02-04 16:17:20 +00:00
|
|
|
'@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,
|
|
|
|
},
|
2019-02-04 14:09:35 +00:00
|
|
|
],
|
2019-02-04 16:17:20 +00:00
|
|
|
[
|
|
|
|
'module-resolver',
|
|
|
|
{
|
2019-04-02 15:41:28 +00:00
|
|
|
root: ['./src'],
|
2019-02-04 16:17:20 +00:00
|
|
|
alias: {
|
2019-04-02 15:41:28 +00:00
|
|
|
public: ['./public'],
|
2019-02-04 16:17:20 +00:00
|
|
|
},
|
2019-02-04 14:09:35 +00:00
|
|
|
},
|
2019-02-04 16:17:20 +00:00
|
|
|
],
|
|
|
|
'babel-plugin-styled-components',
|
|
|
|
];
|
|
|
|
|
|
|
|
if (api.env('test')) {
|
|
|
|
presets.push('jest');
|
|
|
|
}
|
|
|
|
|
2019-02-12 17:37:34 +00:00
|
|
|
if (api.env('translations')) {
|
2019-04-02 15:41:28 +00:00
|
|
|
plugins.push([
|
|
|
|
'react-intl',
|
|
|
|
{
|
|
|
|
messagesDir: './translations/extractedMessages/',
|
|
|
|
extractSourceLocation: true,
|
|
|
|
},
|
|
|
|
]);
|
2019-02-12 17:37:34 +00:00
|
|
|
}
|
|
|
|
|
2019-02-04 16:17:20 +00:00
|
|
|
return {
|
|
|
|
presets,
|
|
|
|
plugins,
|
2019-02-04 14:09:35 +00:00
|
|
|
};
|
2019-04-02 15:41:28 +00:00
|
|
|
};
|