Skip to content

Commit

Permalink
Merge pull request #221 from cofacts/polyfill
Browse files Browse the repository at this point in the history
Add core-js polyfill in webpack
  • Loading branch information
MrOrz authored Feb 27, 2020
2 parents 7a326d2 + 03ce215 commit feae2c8
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
14 changes: 14 additions & 0 deletions next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,20 @@ module.exports = {
publicRuntimeConfig,
serverRuntimeConfig,
webpack(config, { isServer }) {
const originalEntryFn = config.entry;

// Inserting polyfill for old Browsers
// https://github.com/zeit/next.js/blob/canary/examples/with-polyfills/next.config.js
config.entry = async () => {
const entry = await originalEntryFn();
if (entry['main.js'] && !entry['main.js'].includes('core-js')) {
// As specified by React official doc
// https://reactjs.org/docs/javascript-environment-requirements.html
entry['main.js'].unshift('core-js');
}
return entry;
};

//
// Simplified from https://github.com/twopluszero/next-images/blob/master/index.js
//
Expand Down
6 changes: 3 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit feae2c8

Please sign in to comment.