migrate test framework

This commit is contained in:
Shawn Erquhart
2018-07-25 19:17:34 -04:00
parent dc1f41d2d8
commit 1a9fe461ff
16 changed files with 682 additions and 640 deletions

View File

@ -1,11 +1,23 @@
module.exports = {
presets: [
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',
];
}
return [
'@babel/preset-react',
['@babel/preset-env', {
modules: false,
}],
],
plugins: [
];
};
const plugins = () => {
const defaultPlugins = [
'lodash',
['babel-plugin-transform-builtin-extend', {
globals: ['Error']
@ -14,20 +26,42 @@ module.exports = {
'@babel/plugin-proposal-class-properties',
'@babel/plugin-proposal-object-rest-spread',
'@babel/plugin-proposal-export-default-from',
],
env: {
production: {
plugins: [
['emotion', { hoist: true }],
],
},
development: {
plugins: [
['emotion', {
sourceMap: true,
autoLabel: true,
}],
],
},
},
];
if (isProduction) {
return [
...defaultPlugins,
['emotion', { hoist: true }],
];
}
if (isTest) {
return [
...defaultPlugins,
['inline-svg', {
svgo: {
plugins: [
{removeViewBox: false},
],
},
}],
['emotion', {
sourceMap: true,
autoLabel: true,
}],
];
}
return [
...defaultPlugins,
['emotion', {
sourceMap: true,
autoLabel: true,
}],
];
};
module.exports = {
presets: presets(),
plugins: plugins(),
};