module.exports={
entry:{
app:'./app.js'
},
output:{
filename:'[name].[hash:8].js'
},
module:{
rules:[
{
test:/\.js$/,
use:{
loader:'babel-loader',
options:{
presets:['@babel/preset-env',{
targets:{
browsers:['>1%','last 2 versions']
}
}]
}
},
exclude:'/node_modules/'
}
]
}
}
错误提示:
ERROR in ./app.js
Module build failed: ReferenceError: [BABEL] G:\2018\webpack3test\day3\app.js: Unknown option: .targets. Check out http://babeljs.io/docs/usage/options/ for more information about options.
at buildUnknownError (G:\2018\webpack3test\day3\node_modules\@babel\core\lib\config\validation\options.js:97:11)
at G:\2018\webpack3test\day3\node_modules\@babel\core\lib\config\validation\options.js:83:57
at Array.forEach (native)
at validate (G:\2018\webpack3test\day3\node_modules\@babel\core\lib\config\validation\options.js:61:21)
at G:\2018\webpack3test\day3\node_modules\@babel\core\lib\config\index.js:246:36
at cachedFunction (G:\2018\webpack3test\day3\node_modules\@babel\core\lib\config\caching.js:40:17)
at loadPresetDescriptor (G:\2018\webpack3test\day3\node_modules\@babel\core\lib\config\index.js:238:45)
at G:\2018\webpack3test\day3\node_modules\@babel\core\lib\config\index.js:63:19
at Array.map (native)
at recurseDescriptors (G:\2018\webpack3test\day3\node_modules\@babel\core\lib\config\index.js:61:36)
at loadConfig (G:\2018\webpack3test\day3\node_modules\@babel\core\lib\config\index.js:108:6)
at G:\2018\webpack3test\day3\node_modules\@babel\core\lib\transform.js:26:33
at _combinedTickCallback (internal/process/next_tick.js:73:7)
at process._tickCallback (internal/process/next_tick.js:104:9)