报错信息:
目录结构
package.json文件
{
"name": "webpack-text1",
"version": "1.0.0",
"description": "webpack-text1",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "bky",
"license": "ISC",
"devDependencies": {
"css-loader": "^0.26.1",
"html-webpack-plugin": "^1.7.0",
"style-loader": "^0.13.1"
}
}
webpack.config.js 文件
var path = require('path');
var HtmlWebpackPlugin = require('html-webpack-plugin');
module.exports ={
entry: path.join(__dirname,'index'),
output: {
path:__dirname,
filename:'bundle.js'
},
moudle: {
loader: [
{
test:/\.css$/,
loaders:['style','css']
}
]
},
plugins:[
new HtmlWebpackPlugin({
title: 'use plugin'
})
]
}
请各位帮个忙
这有点诡异吧,报错是提示
output.path
参数也就是你代码里的__dirname
是个undefined。或者你试试在最上面用console.log(__dirname)
打印出来看看是什么?