Skip to content
This repository has been archived by the owner on Nov 6, 2020. It is now read-only.

riasvdv/laravel-mix-critical

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 

Repository files navigation

NPM NPM NPM

Laravel Mix Critical

This extension provides instant Critical support to your Mix (v2.1 and up) builds.

Usage

First, install the extension.

npm install laravel-mix-critical --save-dev

Then, require it within your webpack.mix.js file, like so:

let mix = require('laravel-mix');

require('laravel-mix-critical');

mix
    .js('resources/assets/js/app.js', 'public/js')
    .less('resources/assets/less/app.less', 'public/css')
    .critical({
        enabled: mix.inProduction(),
        urls: [
            { src: process.env.BASE_URL + '/', dest: 'public/css/index_critical.min.css' },
        ],
        options: {
            minify: true,
        },
    });

And you're done! Compile everything down with npm run dev.

Options

Only urls is required - all other options are optional.

Name Type Default Description
urls array [] An array of url objects, each with a src and dest: { src: 'http://example.com', dest: 'public/css/index_critical.min.ss' }
enabled boolean mix.inProduction() If generating Critical CSS should be enabled
options object {} An object of Critical options