Files
react/babel.config.js
T
2019-05-01 13:31:55 -07:00

41 lines
1.1 KiB
JavaScript

const chromeManifest = require('./shells/browser/chrome/manifest.json');
const firefoxManifest = require('./shells/browser/firefox/manifest.json');
const minChromeVersion = parseInt(chromeManifest.minimum_chrome_version, 10);
const minFirefoxVersion = parseInt(
firefoxManifest.applications.gecko.strict_min_version,
10
);
validateVersion(minChromeVersion);
validateVersion(minFirefoxVersion);
function validateVersion(version) {
if (version > 0 && version < 200) {
return;
}
throw new Error('Suspicious browser version in manifest: ' + version);
}
module.exports = api => {
const isTest = api.env('test');
const targets = {};
if (isTest) {
targets.node = 'current';
} else {
targets.chrome = minChromeVersion.toString();
targets.firefox = minFirefoxVersion.toString();
}
return {
plugins: [
['@babel/plugin-transform-flow-strip-types'],
['@babel/plugin-proposal-class-properties', { loose: false }],
['@babel/plugin-transform-react-jsx-source'],
],
presets: [
['@babel/preset-env', { targets }],
'@babel/preset-react',
'@babel/preset-flow',
],
};
};