我将尝试并学习webpack及其基础知识,版本为4。在使用加载器和配置时遇到了一些问题。
webpack的配置如下:
module.exports = {
entry: ['./app.js', './util.js'],
output: {
filename: 'bundle.js'
},
module: {
rules: [
{
test: /\.es6$/,
exclude: /node_modules/,
use: 'babel-loader'
},
{
enforce: 'pre',
test: /\.js$/,
exclude: /node_modules/,
use: 'jshint-loader'
}
]
},
resolve: {
extensions: ['.js', '.es6']
}
}
在使用
webpack-dev-server
时,出现了以下错误:ERROR in ./app.js
Module build failed: TypeError: Cannot read property 'jshint' of undefined
at Object.jsHint (/home/sagar/Documents/mine/gitrepo/webpack_illustration/node_modules/jshint-loader/index.js:63:17)
at Object.<anonymous> (/home/sagar/Documents/mine/gitrepo/webpack_illustration/node_modules/jshint-loader/index.js:149:11)
at /home/sagar/Documents/mine/gitrepo/webpack_illustration/node_modules/jshint-loader/index.js:55:5
at tryToString (fs.js:513:3)
at FSReqWrap.readFileAfterClose [as oncomplete] (fs.js:501:12)
@ multi (webpack)-dev-server/client?http://localhost:8080 ./app.js ./util.js