static-cms/babel.config.js

85 lines
1.4 KiB
JavaScript
Raw Normal View History

2018-07-25 19:17:34 -04:00
const isProduction = process.env.NODE_ENV === 'production';
const isTest = process.env.NODE_ENV === 'test';
const presets = () => {
if (isTest) {
return ['@babel/preset-react', '@babel/preset-env'];
2018-07-25 19:17:34 -04:00
}
return [
2018-07-17 19:13:52 -04:00
'@babel/preset-react',
[
'@babel/preset-env',
{
modules: false,
},
],
2018-07-25 19:17:34 -04:00
];
};
const plugins = () => {
const defaultPlugins = [
2018-07-17 19:13:52 -04:00
'lodash',
[
'babel-plugin-transform-builtin-extend',
{
globals: ['Error'],
},
],
2018-07-17 19:13:52 -04:00
'transform-export-extensions',
'@babel/plugin-proposal-class-properties',
'@babel/plugin-proposal-object-rest-spread',
'@babel/plugin-proposal-export-default-from',
'@babel/plugin-syntax-dynamic-import',
2018-07-25 19:17:34 -04:00
];
if (isProduction) {
return [
...defaultPlugins,
[
'emotion',
{
hoist: true,
autoLabel: true,
},
],
];
2018-07-25 19:17:34 -04:00
}
if (isTest) {
return [
...defaultPlugins,
[
'inline-svg',
{
svgo: {
plugins: [{ removeViewBox: false }],
},
2018-07-25 19:17:34 -04:00
},
],
[
'emotion',
{
sourceMap: true,
autoLabel: true,
},
],
2018-07-25 19:17:34 -04:00
];
}
return [
...defaultPlugins,
[
'emotion',
{
sourceMap: true,
autoLabel: true,
},
],
2018-07-25 19:17:34 -04:00
];
};
module.exports = {
presets: presets(),
plugins: plugins(),
2018-07-17 19:13:52 -04:00
};