The plugin works for me but unfortunately at the expense of hot module replacement. I have three plugins, it is only when I remove handlebars-webpack-plugin that hot module replacement works. It appears to be the only factor effecting it.
my webpack.dev.js:
const webpack = require('webpack');
const path = require('path');
const merge = require('webpack-merge');
const common = require('./webpack.common.js');
const HandlebarsPlugin = require("handlebars-webpack-plugin");
module.exports = merge(common, {
devtool: 'eval',
output: {
filename: 'app.js',
publicPath: './src',
path: path.resolve(__dirname, 'src')
},
devServer: {
hot: true,
// activate hot reloading
contentBase: path.resolve(__dirname, 'src'),
// match the output path
publicPath: '/'
// match the output `publicPath`
},
plugins: [
new webpack.HotModuleReplacementPlugin(),
new HandlebarsPlugin({
// path to hbs entry file(s)
entry: path.join(process.cwd(), "src", "index.hbs"),
// output path and filename(s)
// if ommited, the input filepath stripped of its extension will be used
output: path.join(process.cwd(), "src", "[name].html"),
// data passed to main hbs template: `main-template(data)`
//data: require("./src/index.json"),
// or add it as filepath to rebuild data on change using webpack-dev-server
data: path.join(__dirname, "src/index.json")
})
]
});
The plugin works for me but unfortunately at the expense of hot module replacement. I have three plugins, it is only when I remove handlebars-webpack-plugin that hot module replacement works. It appears to be the only factor effecting it.
my webpack.dev.js:
webpack.common.js