Skip to content

mixueXiang/html-inline-css-webpack-plugin

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

html-inline-css-webpack-plugin

MIT Licence PRs Welcome npm version

Convert external style sheet(<link rel="stylesheet"/>) to internal style sheet(<style>...<style/>).

Require mini-css-extract-plugin and html-webpack-plugin

Install

NPM

npm install html-inline-css-webpack-plugin -D

Yarn

yarn add html-inline-css-webpack-plugin -D

Minimal example

const MiniCssExtractPlugin = require("mini-css-extract-plugin");
const HtmlWebpackPlugin = require('html-webpack-plugin');
const HTMLInlineCSSWebpackPlugin = require("html-inline-css-webpack-plugin").default;

module.exports = {
  plugins: [
    new MiniCssExtractPlugin({
      filename: "[name].css",
      chunkFilename: "[id].css"
    }),
    new HtmlWebpackPlugin(),
    new HTMLInlineCSSWebpackPlugin(),
  ],
  module: {
    rules: [
      {
        test: /\.css$/,
        use: [
          MiniCssExtractPlugin.loader,
          "css-loader"
        ]
      }
    ]
  }
}

About

☄️ A webpack plugin for convert external stylesheet to embedded stylesheet

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • TypeScript 100.0%