Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions scripts/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
process.env.BABEL_ENV = 'production';
process.env.NODE_ENV = 'production';

const babelIE11 = require('./patch/babelIE11');
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The babel config needs to be patched before the webpack config, otherwise we're too late and it won't take effect.

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