-
Notifications
You must be signed in to change notification settings - Fork 28.9k
Description
Question about Next.js in IE11
I added Polyfills in my project nextjs, but all the scripts js are not functional in IE11 (internet explorer):
https://github.com/zeit/next.js/tree/canary/examples/with-polyfills
// polyfills.js
/* eslint no-extend-native: 0 */
// core-js comes with Next.js. So, you can import it like below
import includes from 'core-js/es/string/virtual/includes';
import repeat from 'core-js/es/string/virtual/repeat';
import assign from 'core-js/es/object/assign';
// add your polyfills
// This files runs at the very beginning (even before React and Next.js core)
console.log('Load your polyfills');
String.prototype.includes = includes;
String.prototype.repeat = repeat;
Object.assign = assign;
// next.confg.js
`require('dotenv').config();
const path = require('path');
const Dotenv = require('dotenv-webpack');
const withCSS = require('@zeit/next-css');
console.log(__dirname);
module.exports = withCSS({
cssLoaderOptions: {
url: false,
},
distDir: '../build',
pageExtensions: ['jsx', 'js'],
webpack: config => {
const originalEntry = config.entry;
config.entry = async () => {
const entries = await originalEntry();
if (entries['main.js'] && !entries['main.js'].includes('./client/polyfills.js')) {
entries['main.js'].unshift('./client/polyfills.js');
}
return entries;
};
config.module.rules.push({
test: /\.(png|jpg|gif|svg|eot|ttf|woff|woff2)$/,
use: {
loader: 'url-loader',
options: {
limit: 100000,
},
},
});
config.plugins = config.plugins || [];
config.plugins = [
...config.plugins,
// Read the .env file
new Dotenv({
path: path.join(__dirname, '.env'),
systemvars: true,
}),
];
return config;
},
});
`