Skip to content
This repository has been archived by the owner on Jul 23, 2019. It is now read-only.

manhtai/webpack-critical-css-plugin

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Webpack critical css plugin

About

This is a Webpack plugin for generating critical css using penthouse. It creates a new file in the chunk with suffix .critical before file extension.

Eg:

Your output: styles.css

New output: styles.critical.css

Install

yarn add --dev webpack-critical-css-plugin

Usage

In your webpack.config.js:

const CriticalCssPlugin = require("webpack-critical-css-plugin");


const criticalHTML = {
  yourChunk: "file:///"   path.join(__dirname, "example.com.html"), // local html file
  anotherChunk: "https://example.com" // live url
};

entry: {
  yourChunk: path.join(__dirname, "yourChunk"),
  anotherChunk: path.join(__dirname, "anotherChunk"),
  yetAnotherChunk: path.join(__dirname, "yetAnotherChunkChunk"),
  ...
}

plugins: [
  ...,
  new CriticalCssPlugin({
    criticalHTML
  }),
  ...,
]

Author

Mạnh Tài

About

Webpack critical css plugin using penthouse

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published