javascriptwebpackcritical-css

Criticalcss on initial build with webpack fails


So I'm using Webpack to bundle up my js and css.

I've added the Webpack-plugin-critical to output an external css file featuring critical styles. This file gets added to my (twig) template.

It works fine if I run Webpack a second time, though the initial build fails and I get an error saying it can't find the primary generated css file. How do I expose the primary css file output from ExtractTextPlugin to Webpack-plugin-critical allowing it to consume the file and produce a critical css file on initial build?


Solution

  • For any one stuck on this. Use this plugin; https://www.npmjs.com/package/html-critical-webpack-plugin

    It builds the critical styles AFTER the sass has been compiled.