Inlining Images & Fonts in CSS

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.

Web アプリケーションのパフォーマンスを向上させる簡単な手法は、生成された CSS ファイルで base64 エンコードされた URL として小さなファイルをインライン化する HTTP 要求の数を減らすことです。

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

画像、フォント、またはその両方に対して webpack.config.js でこれを有効にできます。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
// 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.

これは、Webpack アセット モジュールを活用します。これと構成の詳細については、こちらを参照してください。