Skip to content

Changes when using webpck watch mode do not regenerate the HTML file #66

@zlangbert

Description

@zlangbert

I am having an issue where when running webpack in watch mode changes to the source that gets inlined does not trigger a rebuild of the html file.

Environment and package version

Webpack 5.27.2, HTML webpack plugin 5.3.1 , HTML inline script plugin 2.0.0

Reproduction link / code sample

Here is my webpack config which hopefully gives you an idea of the setup.

const path = require('path')
const CopyPlugin = require("copy-webpack-plugin");
const HtmlWebpackPlugin = require('html-webpack-plugin')
const HtmlInlineScriptPlugin = require('html-inline-script-webpack-plugin');

module.exports = (env, argv) => ({
  mode: argv.mode === 'production' ? 'production' : 'development'
  entry: {
    ui: './src/ui/ui.tsx',
  },
  module: {
    rules: [
      { test: /\.tsx?$/, use: 'ts-loader', exclude: /node_modules/ },
      { test: /\.css$/, use: [{ loader: 'style-loader' }, { loader: 'css-loader' }] },
      {
        test: /\.(png|jpg|gif|webp|svg|zip)$/,
        type: "asset/inline"
      },
    ],
  },
  resolve: { extensions: ['.tsx', '.ts', '.jsx', '.js'] },
  output: {
    filename: '[name].js',
    path: path.resolve(__dirname, 'dist'),
  },
  plugins: [
    new CopyPlugin({
      patterns: [
        { from: "src/manifest.json", },
      ],
    }),
    new HtmlWebpackPlugin({
      template: './src/ui/ui.html',
      filename: 'ui.html',
      chunks: ['ui'],
    }),
    new HtmlInlineScriptPlugin([/ui.js/]),
  ],
})

Steps to reproduce

  1. Run webpack --watch
  2. Make a change to ui.tsx

Webpack logs show that ui.tsx is regenerated but ui.html is not emitted. However if I change the HTML file itself ui.html does get emitted.

What is expected?

I would expect that the HTML file is regenerated when the code that is being inlined is changed.

What is actually happening?

Webpack does not regenerate the HTML file and no changes are actually written.

Let me know if you need any more info, thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions