Skip to content

Commit

Permalink
Set Babel’s IE target from 9 to 11
Browse files Browse the repository at this point in the history
  • Loading branch information
Daniel Spitzer committed Apr 22, 2018
1 parent 14e78d5 commit 16a6b59
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 0 deletions.
5 changes: 5 additions & 0 deletions scripts/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@
process.env.BABEL_ENV = 'production';
process.env.NODE_ENV = 'production';


const babelIE11 = require('./patch/babelIE11');
const babelConfig = require('babel-preset-react-app');
babelIE11(babelConfig);

const webpackPreact = require('./patch/webpackPreact');
const webpackConfig = require('react-scripts/config/webpack.config.prod');
webpackPreact(webpackConfig);
Expand Down
14 changes: 14 additions & 0 deletions scripts/patch/babelIE11.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// Hack babel to build for IE11 instead of IE9
module.exports = babelConfig => {
const presets = babelConfig.presets;
presets.forEach((preset, i) => {
if (!Array.isArray(preset)) {
return;
}
preset.forEach((p, j) => {
if (p.targets && p.targets.ie) {
presets[i][j].ie = 11;
}
});
});
};
4 changes: 4 additions & 0 deletions scripts/start.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
process.env.BABEL_ENV = 'development';
process.env.NODE_ENV = 'development';

const babelIE11 = require('./patch/babelIE11');
const babelConfig = require('babel-preset-react-app');
babelIE11(babelConfig);

const webpackPreact = require('./patch/webpackPreact');
const webpackConfig = require('react-scripts/config/webpack.config.dev');
webpackPreact(webpackConfig);
Expand Down

0 comments on commit 16a6b59

Please sign in to comment.