1
0
mirror of https://github.com/Unleash/unleash.git synced 2024-12-28 00:06:53 +01:00
unleash.unleash/frontend/craco.config.js
Fredrik Strand Oseberg ad09c4039a Fix/strategy constraints (#289)
* fix: only update editable strategies if index is less than 0

* fix: add wdyr

* fix: set tracking to false as default

* chore: update readme
2021-05-07 08:31:25 +02:00

38 lines
1.3 KiB
JavaScript

const presetReact = require('@babel/preset-react').default;
const presetCRA = require('babel-preset-react-app');
module.exports = {
babel: {
loaderOptions: (babelLoaderOptions, { env, paths }) => {
const origBabelPresetReactAppIndex = babelLoaderOptions.presets.findIndex(
preset => {
return preset[0].includes('babel-preset-react-app');
}
);
if (origBabelPresetReactAppIndex === -1) {
return babelLoaderOptions;
}
const overridenBabelPresetReactApp = (...args) => {
const babelPresetReactAppResult = presetCRA(...args);
const origPresetReact = babelPresetReactAppResult.presets.find(
preset => {
return preset[0] === presetReact;
}
);
Object.assign(origPresetReact[1], {
importSource: '@welldone-software/why-did-you-render',
});
return babelPresetReactAppResult;
};
babelLoaderOptions.presets[
origBabelPresetReactAppIndex
] = overridenBabelPresetReactApp;
return babelLoaderOptions;
},
},
};