chore: fix babel config (#2714)

This commit is contained in:
Shawn Erquhart 2019-09-30 15:24:15 -04:00 committed by GitHub
parent 9076530238
commit afbc15d59b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -7,11 +7,6 @@ const isESM = process.env.NODE_ENV === 'esm';
console.log('Build Package:', path.basename(process.cwd()));
const presets = () => {
return ['@babel/preset-react', '@babel/preset-env'];
};
const plugins = () => {
const defaultPlugins = [
'lodash',
[
@ -24,13 +19,6 @@ const plugins = () => {
'@babel/plugin-proposal-class-properties',
'@babel/plugin-proposal-object-rest-spread',
'@babel/plugin-proposal-export-default-from',
[
'emotion',
{
sourceMap: true,
autoLabel: true,
},
],
[
'module-resolver',
isESM
@ -78,9 +66,22 @@ const plugins = () => {
],
];
const presets = () => {
return ['@babel/preset-react', '@babel/preset-env'];
};
const plugins = () => {
if (isESM) {
return [
...defaultPlugins,
[
'emotion',
{
sourceMap: true,
autoLabel: true,
},
],
[
'transform-define',
{
@ -121,10 +122,29 @@ const plugins = () => {
}
if (!isProduction) {
defaultPlugins.push('react-hot-loader/babel');
return [
...defaultPlugins,
[
'emotion',
{
sourceMap: true,
autoLabel: true,
},
],
'react-hot-loader/babel',
];
}
return defaultPlugins;
return [
...defaultPlugins,
[
'emotion',
{
sourceMap: true,
autoLabel: true,
},
],
];
};
module.exports = {