已經按webpack2 的版本配置還是出錯,有沒有朋友給看看
var?htmlWebpackPlugin?=?require('html-webpack-plugin');
module.exports?=?{
entry:?__dirname?+?'/src/app.js',
output:?{
path:?__dirname?+?"/dist",
filename:?'js/[name]-bundle.js'
},
plugins:?[
new?htmlWebpackPlugin({
filename:?'newindex.html',
template:?'index.html',
inject:?'body'
})
],
module:?{
rules:?[{
test:?'/\.js$/',
use:?[{
????loader:?'babel-loader',
????options:?{
"presets":?"env"
}
}]
}
]
}
}報錯信息如下:
ERROR?in?./src/app.js
Module?not?found:?Error:?Can't?resolve?'components/layer/layer.js'?in?'F:\imooc\webpack-demo\src'
?@?./src/app.js?1:0-45
Child?html-webpack-plugin?for?"newindex.html":
???????[0]?./~/lodash/lodash.js?540?kB?{0}?[built]
???????????cjs?require?./node_modules/lodash/lodash.js?[1]?./~/html-webpack-plugin/lib/loader.js!./index.html?1:8-50
???????[1]?./~/html-webpack-plugin/lib/loader.js!./index.html?503?bytes?{0}?[built]
???????[2]?(webpack)/buildin/global.js?509?bytes?{0}?[built]
???????????cjs?require?global?[0]?./~/lodash/lodash.js?1:0-41
???????[3]?(webpack)/buildin/module.js?517?bytes?{0}?[built]
???????????cjs?require?module?[0]?./~/lodash/lodash.js?1:0-41
2017-05-10
根據提示將 錯誤鎖定在了layer.js里 就去layer.js里去查找,在layer.js里找到了兩處錯誤。修改后,成功了。