Reactjs,Webpack 无法在 IE 11 上运行
Reactjs, Webpack not working on IE 11
当我尝试 运行 我的 React 站点时,我在 IE 中遇到这个错误。它适用于所有其他浏览器,我尝试以多种方式加载 babel-polyfill。
IE 11 错误:
这是我的 webpack.dev.config.js 文件
const path = require('path');
module.exports = {
devtool: "source-map",
mode: 'production',
entry: {
app: ['babel-polyfill', './index.js']
},
output: {
filename: 'bundle.js',
path: path.resolve(__dirname, '/dist')
},
module: {
rules: [{
test: /\.js$/,
enforce: "pre",
exclude: /node_modules/,
use: [{
loader: 'babel-loader',
query: {
presets: ['es2015', 'react', 'stage-0']
}
}]
},
{
test: /\.css$/,
loader: [ 'style-loader', 'css-loader' ]
},
{
test: /\.scss$/,
loaders: ["style-loader", "css-loader", "sass-loader"]
},
{
test: /\.(png|jpg|gif)$/,
use: [
{
loader: 'file-loader',
}]
},
{
test: /\.(woff(2)?|ttf|eot|svg)(\?v=\d+\.\d+\.\d+)?$/,
use: [{
loader: 'file-loader',
options: {
name: '[name].[ext]',
outputPath: 'fonts/'
}
}]
}]
},
};
我似乎无法修复此错误任何帮助将不胜感激
抱歉,我真的 post 没有足够的信息让任何人解决这个问题,因为问题不在 webpack.dev.config.js 文件中。问题出在我的一个 React 文件中:
publicIP().then(ip =>{
//code here
});
由于 IE 不支持 ES6,因此 => 导致了错误!
当我尝试 运行 我的 React 站点时,我在 IE 中遇到这个错误。它适用于所有其他浏览器,我尝试以多种方式加载 babel-polyfill。
IE 11 错误:
这是我的 webpack.dev.config.js 文件
const path = require('path');
module.exports = {
devtool: "source-map",
mode: 'production',
entry: {
app: ['babel-polyfill', './index.js']
},
output: {
filename: 'bundle.js',
path: path.resolve(__dirname, '/dist')
},
module: {
rules: [{
test: /\.js$/,
enforce: "pre",
exclude: /node_modules/,
use: [{
loader: 'babel-loader',
query: {
presets: ['es2015', 'react', 'stage-0']
}
}]
},
{
test: /\.css$/,
loader: [ 'style-loader', 'css-loader' ]
},
{
test: /\.scss$/,
loaders: ["style-loader", "css-loader", "sass-loader"]
},
{
test: /\.(png|jpg|gif)$/,
use: [
{
loader: 'file-loader',
}]
},
{
test: /\.(woff(2)?|ttf|eot|svg)(\?v=\d+\.\d+\.\d+)?$/,
use: [{
loader: 'file-loader',
options: {
name: '[name].[ext]',
outputPath: 'fonts/'
}
}]
}]
},
};
我似乎无法修复此错误任何帮助将不胜感激
抱歉,我真的 post 没有足够的信息让任何人解决这个问题,因为问题不在 webpack.dev.config.js 文件中。问题出在我的一个 React 文件中:
publicIP().then(ip =>{
//code here
});
由于 IE 不支持 ES6,因此 => 导致了错误!