Skip to content

Latest commit

 

History

History
32 lines (24 loc) · 906 Bytes

url-loader.rst

File metadata and controls

32 lines (24 loc) · 906 Bytes

Inlining Images & Fonts in CSS with Webpack Encore

A simple technique to improve the performance of web applications is to reduce the number of HTTP requests inlining small files as base64 encoded URLs in the generated CSS files.

You can enable this in webpack.config.js for images, fonts or both:

// webpack.config.js
// ...

Encore
    // ...
    .configureImageRule({
        // tell Webpack it should consider inlining
        type: 'asset',
        //maxSize: 4 * 1024, // 4 kb - the default is 8kb
    })

    .configureFontRule({
        type: 'asset',
        //maxSize: 4 * 1024
    })
;

This leverages Webpack Asset Modules. You can read more about this and the configuration there.