babel配置报错
来源:3-12 使用 Babel 处理 ES6 语法(2)
慕粉4324644
2019-10-08
module: {
rules: [
{
test: /\.m?js$/,
exclude: /(node_modules|bower_components)/,
use: {
loader: 'babel-loader',
options: {
presets: ['@babel/preset-env'],
plugins: ['@babel/plugin-transform-runtime']
}
}
}
]
}
老师我按照webpack官网上这样配置babel是可以正常打包的,但是如果加上参数
rules: [
{
test: /\.(js)$/,
use: {
loader: 'babel-loader',
options: {
"presets": ['@babel/preset-env'],
"plugins": [['@babel/plugin-transform-runtime'] ,
{
"absoluteRuntime": false,
"corejs": false,
"helpers": true,
"regenerator": true,
"useESModules": false
}
]
}
},
exclude: /node_modules/
},
这样就会报错,不知道为什么。
ERROR in ./src/index.js
Module build failed (from ./node_modules/_babel-loader@8.0.6@babel-loader/lib/index.js):
Error: [BABEL] D:\work_file\mayun\webpack\src\index.js: .absoluteRuntime is not a valid Plugin property
at Object.keys.forEach.key (D:\work_file\mayun\webpack\node_modules\_@babel_core@7.6.2@@babel\core\lib\config\validation\plugins.js:61:59)
写回答
1回答
-
慕粉4324644
提问者
2019-10-08
自己找到原因了,
"plugins": [['@babel/plugin-transform-runtime',
{
"absoluteRuntime": false,
"corejs": false,
"helpers": true,
"regenerator": true,
"useESModules": false
}
]]这里写成这样就好了
00
相似问题