Answer the question
In order to leave comments, you need to log in
How to make webpack-dev-server watch for files we don't include as dependencies?
Good afternoon!
Understanding Webpack. As far as I know, webpack-dev-server monitors and rebuilds the build if there have been changes in any of the files in the dependencies on the entry point (entry). I am using html-webpack-plugin and pug template engine i.e. I do not connect this file anywhere through require. But when changing in the pug file, although webpack-dev-server rebuilds the assembly (visible in the console), the changes that I made to pug are not displayed on the screen. You have to restart the browser manually. And this is very, very annoying!
I want to ask those who are in the subject how to solve this problem !!!
My webpack.config.js
let HtmlWebpackPlugin = require('html-webpack-plugin');
let HtmlWebpackPugPlugin = require('html-webpack-pug-plugin');
let webpack = require('webpack');
let ExtractTextPlugin = require('extract-text-webpack-plugin');
let path = require('path');
module.exports = {
entry: './src/app.js',
output: {
path: path.resolve(__dirname,'dist'),
filename: 'bundle.js'
},
module: {
rules: [
{
test: /\.js$/,
exclude: /node_modules/,
loader: 'babel-loader'
},
{
test: /\.css$/,
use: ExtractTextPlugin.extract({
fallback: 'style-loader',
use: ['css-loader','postcss-loader']
})
},
{
test: /\.pug$/,
loader: 'html-loader!pug-html-loader'
}
]
},
devServer: {
contentBase: path.join(__dirname, "dist"),
compress: true,
stats: 'normal',
hot: true
},
plugins: [
new HtmlWebpackPlugin({
template: 'src/index.pug'
}),
new ExtractTextPlugin('css/style.css'),
new HtmlWebpackPugPlugin()
]
};
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question