在學習 webpack 的時候碰到個配置 plugin 的問題,具體代碼如下:
var path = require('path');
var HtmlWebpackPlugin = require('html-webpack-plugin');
module.exports = {
entry: path.join(__dirname, 'index'),
output: {
path: __dirname,
filename: 'bundle.js'
},
module: {
loaders: [
{
test: /\.css$/,
loaders: ['style', 'css']
}
]
},
plugins: [
new HtmlWebpackPlugin({
title: 'use plugin'
})
]
};
文件路徑如下:
其中的 index.html 一開始是沒有的 后續(xù) webpack 編譯生成的.
執(zhí)行 webpack 的時候報錯:
后來看到一位博主給的解決辦法:
plugin 配置里面加個 filename: 'index.html' 即可.
特此記錄