pug-loader: Webpack do not reload on included file change
Hello đđ»
I want to use WebpackDevServer with pug-loader. My problem is that, itâs not reloading the page after change in included files.
Any ideas what am I doing wrong?
My webpack.config.js:
var HtmlWebpackPlugin = require('html-webpack-plugin');
var path = require('path');
var webpack = require('webpack');
module.exports = {
devtool: 'eval',
cache: true,
debug: true,
entry: [
'webpack-dev-server/client?http://localhost:3000/',
'webpack/hot/only-dev-server',
'./src/index.js'
],
output: {
path: path.join(__dirname, 'build'),
filename: 'test.bundle.js',
publicPath: '/'
},
plugins: [
new webpack.HotModuleReplacementPlugin(),
new webpack.optimize.UglifyJsPlugin(),
new HtmlWebpackPlugin({
filename: 'index.html',
template: './src/index.pug',
title: 'Pug webiste'
}),
new webpack.ResolverPlugin(
new webpack.ResolverPlugin.DirectoryDescriptionFilePlugin(".bower.json", [ "main" ])
)
],
module: {
loaders: [
{
test: /\.js$/,
loader: [ 'babel-loader' ],
exclude: /(node_modules|bower_components)/,
include: path.join(__dirname, 'src'),
query: {
presets: [ 'es2015' ]
}
}, {
test: /\.scss$/,
loaders: [ "style-loader", "css-loader?sourceMap", "sass-loader?sourceMap" ]
}, {
test: /\.pug$/,
include: path.join(__dirname, 'src'),
loaders: [ 'pug-html-loader' ]
}
]
},
resolve: {
modulesDirectories: [ "node_modules", "bower_components" ]
}
};
server.js:
var webpack = require('webpack');
var WebpackDevServer = require('webpack-dev-server');
var config = require('./webpack.config');
new WebpackDevServer(webpack(config), {
publicPath: config.output.publicPath,
hot: false,
quiet: false,
stats: {
colors: true,
reasons: true
},
historyApiFallback: true,
}).listen(3000, 'localhost', function (err, result) {
if (err) {
return console.log(err);
}
console.log('Listening at http://localhost:3000/');
})
About this issue
- Original URL
- State: open
- Created 8 years ago
- Reactions: 1
- Comments: 20
Commits related to this issue
- FIXED Module Replacement (HMR) don't reload PUG files changes https://github.com/pugjs/pug-loader/issues/75#issuecomment-404650894 — committed to thun88/webpack-example by deleted user 5 years ago
I remember when I handled this problem, and now I come back to share my new improvement.
https://github.com/pugjs/pug-loader/issues/75#issuecomment-342122079
I SOLVED whit this npm module. webpack-livereload-plugin
Managed to get it worked without importing pug in js. Use this: https://github.com/jantimon/html-webpack-harddisk-plugin
I have the same problem. HTML files are not updated with Webpack Dev Server when I modified a PUG template.
@OrionPro if you use the Module Replacement (HMR) No, donât resolve that problem. But if you use only DevServer, it is reloading perfect.