Webpack 5, How to make live reload when I update html file after the service run

Viewed 7

I want the server reload the page automatic when I update the html file but I keep getting error.

[webpack-dev-middleware] HookWebpackError: Path variable [id] not implemented in this context: [id].[fullhash].hot-update.js

I am not sure if I set the dev-server correctly or the plugin I use make this error.

const path = require("path");
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
const HtmlWebpackPlugin = require("html-webpack-plugin");

module.exports = {
  entry: "./src/index.js",
  output: {
    path: path.resolve(__dirname, "dist"),
    filename: "main.js",
  },
  mode: "development",
  devtool: "source-map",
  module: {
    rules: [
      {
        test: /\.css$/,
        use: ["style-loader", "css-loader"],
      },

      {
        test: /\.html$/,
        use: ["html-loader"],
      },
    ],
  },
  plugins: [
    new MiniCssExtractPlugin(),
    new HtmlWebpackPlugin({
      title: "Bootstrap 2",
      template: "src/index.html",
      filename: "index.html",
    }),
  ],
  optimization: {
    chunkIds: false,
  },
  devServer: {
    port: 9000,
    historyApiFallback: true,
    hot: true,
    static: path.resolve(__dirname,"dist")
  },
};
0 Answers
Related