A webpack plugin that converts external stylesheets (from MiniCssExtractPlugin) into embedded <style> tags in the HTML output. Current stable version is 1.11.2. It works with webpack 4/5, html-webpack-plugin v3-5, and requires mini-css-extract-plugin. Key differentiators: supports filtering files, custom style tag factory, optional leave CSS file, and custom injection position via replace config. This is a simple, focused plugin with no extra dependencies beyond its peer deps. Ship TypeScript types. Actively maintained.
npm install html-inline-css-webpack-pluginVerified import paths — ran on the pinned version, not inferred.
Minimal webpack config to inline all extracted CSS into <style> tags in HTML.
Use require('html-inline-css-webpack-plugin').default instead of require('html-inline-css-webpack-plugin')Disable comment removal in html-webpack-plugin config: new HtmlWebpackPlugin({ minify: { removeComments: false } })Add logic to distinguish file types, e.g., fileName.endsWith('.css')Ensure HTMLInlineCSSWebpackPlugin is listed after both in plugins array
Use import HTMLInlineCSSWebpackPlugin from 'html-inline-css-webpack-plugin' or require('...').defaultChange const HTMLInlineCSSWebpackPlugin = require('html-inline-css-webpack-plugin') to require('html-inline-css-webpack-plugin').defaultnpm install html-webpack-plugin -D
npm install mini-css-extract-plugin -D
Reorder plugins: list HTMLInlineCSSWebpackPlugin after MiniCssExtractPlugin and HtmlWebpackPlugin
Ensure webpack rules for .css use MiniCssExtractPlugin.loader and css-loader