webpack corejs配置报错
原因:新的配置多了个中括号[]
- 错误代码
{
test: /\.js$/,
exclude: /node_modules/,
loader: ‘babel-loader‘,
options: {
presets: [‘@babel/preset-env‘,
{
//按需加载
useBuiltIns: ‘usage‘,
corejs: {
version: 3
},
//指定兼容性做到哪个版本的浏览器
targets: {
chrome: ‘60‘,
firefox: ‘60‘,
ie: ‘9‘,
safari: ‘10‘
}
}
]
}
},
- 正确代码
{
test: /\.js$/,
exclude: /node_modules/,
loader: ‘babel-loader‘,
options: {
presets: [[‘@babel/preset-env‘,
{
//按需加载
useBuiltIns: ‘usage‘,
corejs: {
version: 3
},
//指定兼容性做到哪个版本的浏览器
targets: {
chrome: ‘60‘,
firefox: ‘60‘,
ie: ‘9‘,
safari: ‘10‘
}
}
]]
}
},