A Webpack plugin that converts external <script src> tags to inline <script> blocks, removing the original asset from build output. Current stable version 3.2.1 (Aug 2023) supports Webpack 5; use v1.x for Webpack 4. Requires html-webpack-plugin ^5.0.0 as a peer dependency. Key differentiators: regex-based matching for selective inlining (scriptMatchPattern, htmlMatchPattern), asset preservation (assetPreservePattern), and automatic escaping of </script> inside source code. Updated at a moderate pace with minor and patch releases quarterly. Compatible with multiple HtmlWebpackPlugin instances and respects public path configuration.
npm install html-inline-script-webpack-pluginVerified import paths — ran on the pinned version, not inferred.
Basic Webpack config with HtmlWebpackPlugin and HtmlInlineScriptPlugin to inline the bundle.js script into the HTML output.
Ensure webpack ^5.0.0 and html-webpack-plugin ^5.0.0 are installed.
Upgrade to v3.x and update peer dependencies for Webpack 5.
Add `assetPreservePattern: [/regex/]` to plugin options.
Use patterns like `/runtime~.+[.]js$/` to match output chunks with hashes.
Always add `new HtmlWebpackPlugin()` before `new HtmlInlineScriptPlugin()`.
Use `const HtmlInlineScriptPlugin = require('html-inline-script-webpack-plugin');`Add `new HtmlWebpackPlugin()` to the plugins array.
Run `npm install --save-dev html-webpack-plugin`.