像这样配置 webpack + babel
webpack.config.js
...
module: {
rules: [
{
test: /\.(js|jsx)$/,
exclude: /node_modules/,
loader: 'babel-loader'
},
...
.babelrc
{
"plugins": ["lodash", "transform-object-rest-spread"],
"presets": [
["env", {
"targets": [
"> 4%",
"ie 11",
"safari 8"
]
}],
"react",
"react-optimize"
],
"env": {
"test": {
"presets": ["es2015", "react"]
}
}
}
我在 chrom 中运行一切正常,在 IE 11 中它给出了一个错误
对象不支持属性或方法“分配”
向 Node JS 添加包
添加到使用 object.assing 的文件后
来自这里的信息: https://github.com/aspnet/JavaScriptServices/wiki/Supporting-Internet-Explorer-11-(or-older)
.babelrc