不浪漫
2017-05-10 18:23
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
根据提示将 错误锁定在了layer.js里 就去layer.js里去查找,在layer.js里找到了两处错误。修改后,成功了。
webpack深入与实战
86561 学习 · 721 问题
相似问题