File tree Expand file tree Collapse file tree 2 files changed +45
-0
lines changed Expand file tree Collapse file tree 2 files changed +45
-0
lines changed Original file line number Diff line number Diff line change @@ -53,6 +53,7 @@ Optimizing
5353* :doc: `Versioning (and the manifest.json file) </frontend/encore/versioning >`
5454* :doc: `Using A CDN </frontend/encore/cdn >`
5555* :doc: `Creating a "Shared" entry for re-used modules </frontend/encore/shared-entry >`
56+ * :doc: `Using the URL Loader </frontend/encore/url-loader >`
5657
5758Guides
5859......
Original file line number Diff line number Diff line change 1+ Using the URL Loader
2+ ===============================
3+
4+ The `URL Loader `_ allows you to convert files into Data URLs and embed them
5+ directly into the compiled version of your code. This can be useful if you
6+ want to avoid extra network requests for some of the ``url() `` calls present
7+ in your CSS files.
8+
9+ In Encore that loader is disabled by default, but you can easily enable it for
10+ images and fonts.
11+
12+ First, add the loader to your project:
13+
14+ .. code-block :: terminal
15+
16+ $ yarn add --dev url-loader
17+
18+ Then enable it in your ``webpack.config.js ``:
19+
20+ .. code-block :: javascript
21+
22+ // webpack.config.js
23+ // ...
24+
25+ Encore
26+ // ...
27+ .configureUrlLoader ({
28+ fonts: { limit: 4096 },
29+ images: { limit: 4096 }
30+ })
31+ ;
32+
33+ Every fonts and images files having a size below or equal to 4 KB will now be
34+ inlined directly where they are required. If their size is over 4 KB the default
35+ behavior will be used instead. You can change that threshold by modifying the
36+ ``limit `` option.
37+
38+ You can also use all of the other options supported by the `URL Loader `_.
39+
40+ If you wish to disable that loader for either images or fonts simply remove the
41+ corresponding key from the object that is passed to the ``configureUrlLoader() ``
42+ method.
43+
44+ .. _`URL loader` : https://github.com/webpack-contrib/url-loader
You can’t perform that action at this time.
0 commit comments