Skip to content

Commit 16a6b59

Browse files
author
Daniel Spitzer
committed
Set Babel’s IE target from 9 to 11
1 parent 14e78d5 commit 16a6b59

File tree

3 files changed

+23
-0
lines changed

3 files changed

+23
-0
lines changed

scripts/build.js

+5
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,11 @@
33
process.env.BABEL_ENV = 'production';
44
process.env.NODE_ENV = 'production';
55

6+
7+
const babelIE11 = require('./patch/babelIE11');
8+
const babelConfig = require('babel-preset-react-app');
9+
babelIE11(babelConfig);
10+
611
const webpackPreact = require('./patch/webpackPreact');
712
const webpackConfig = require('react-scripts/config/webpack.config.prod');
813
webpackPreact(webpackConfig);

scripts/patch/babelIE11.js

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// Hack babel to build for IE11 instead of IE9
2+
module.exports = babelConfig => {
3+
const presets = babelConfig.presets;
4+
presets.forEach((preset, i) => {
5+
if (!Array.isArray(preset)) {
6+
return;
7+
}
8+
preset.forEach((p, j) => {
9+
if (p.targets && p.targets.ie) {
10+
presets[i][j].ie = 11;
11+
}
12+
});
13+
});
14+
};

scripts/start.js

+4
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@
33
process.env.BABEL_ENV = 'development';
44
process.env.NODE_ENV = 'development';
55

6+
const babelIE11 = require('./patch/babelIE11');
7+
const babelConfig = require('babel-preset-react-app');
8+
babelIE11(babelConfig);
9+
610
const webpackPreact = require('./patch/webpackPreact');
711
const webpackConfig = require('react-scripts/config/webpack.config.dev');
812
webpackPreact(webpackConfig);

0 commit comments

Comments
 (0)