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