This is a basic example to show how I set up my critical CSS and how I use the postcss-critical-spit plugin (located at https://www.npmjs.com/package/postcss-critical-split).
- Clone the repository
- Open a Terminal window in the main project folder
- run
npm install
- run
gulp cleanto empty the build directory. This comes in handy when trying the seperate setups
- run
gulp css:sassfirst (this is to generate the input CSS file) - run
node postcss.jsto run the Node task that runs the direct PostCSS task without Gulp.
- Run
npm run gulpto generate the files and run a local server with development setup - Run 'gulp --release' to generate the files and run a local server with release (aka critically-rendered) assets
- Check out the
Gulpfileand themain-critical.cssfile in thebuild/cssfolder to see what happens
- Run
npm run webpackto generate the files - There is no fully embedded CSS in the HTML file now but that shouldn't stop you :)
- Check out the
webpack.config.fileto see how the multiple CSS files are generated in a single go! Thanks to Vladimir Kuznetsov for helping out!