2019-08-27 09:35:54 +00:00
|
|
|
module.exports = api => {
|
2019-11-05 14:39:37 +00:00
|
|
|
const isExtract = api.env("extract");
|
2019-08-27 09:35:54 +00:00
|
|
|
const isTest = api.env("test");
|
2019-08-27 11:02:47 +00:00
|
|
|
const isStorybook = api.env("storybook");
|
2019-08-27 09:35:54 +00:00
|
|
|
|
2019-08-27 11:02:47 +00:00
|
|
|
const ignore =
|
|
|
|
isTest || isStorybook
|
|
|
|
? []
|
|
|
|
: ["**/*.test.ts", "**/*.test.tsx", "src/storybook"];
|
2019-08-27 09:35:54 +00:00
|
|
|
|
2019-08-27 11:02:47 +00:00
|
|
|
const presets = [
|
|
|
|
[
|
|
|
|
"@babel/preset-env",
|
|
|
|
{
|
|
|
|
corejs: "3.2.1",
|
|
|
|
modules: isTest ? "auto" : false,
|
|
|
|
useBuiltIns: "usage"
|
|
|
|
}
|
2019-08-27 09:35:54 +00:00
|
|
|
],
|
2019-08-27 11:02:47 +00:00
|
|
|
"@babel/preset-react",
|
|
|
|
"@babel/preset-typescript"
|
|
|
|
];
|
|
|
|
|
|
|
|
const plugins = [
|
|
|
|
"@babel/plugin-proposal-numeric-separator",
|
|
|
|
"@babel/plugin-proposal-class-properties",
|
|
|
|
[
|
|
|
|
"@babel/plugin-proposal-decorators",
|
|
|
|
{
|
|
|
|
decoratorsBeforeExport: true
|
|
|
|
}
|
2019-08-27 09:35:54 +00:00
|
|
|
],
|
2019-08-27 11:02:47 +00:00
|
|
|
"@babel/plugin-proposal-object-rest-spread",
|
2019-11-05 14:39:37 +00:00
|
|
|
"react-intl-auto"
|
|
|
|
];
|
|
|
|
|
|
|
|
if (isExtract) {
|
|
|
|
plugins.push([
|
2019-08-27 11:02:47 +00:00
|
|
|
"react-intl",
|
|
|
|
{
|
|
|
|
extractFromFormatMessageCall: true,
|
|
|
|
messagesDir: "build/locale/"
|
|
|
|
}
|
2019-11-05 14:39:37 +00:00
|
|
|
]);
|
|
|
|
}
|
|
|
|
|
|
|
|
plugins.push("macros");
|
2019-08-27 11:02:47 +00:00
|
|
|
|
|
|
|
return {
|
|
|
|
presets,
|
|
|
|
plugins,
|
2019-08-27 09:35:54 +00:00
|
|
|
ignore
|
|
|
|
};
|
|
|
|
};
|