Commit 5145ed4
committed
feature #45845 [TwigBundle] Pre-compile only *.twig files in cache warmup (GromNaN)
This PR was merged into the 6.1 branch.
Discussion
----------
[TwigBundle] Pre-compile only *.twig files in cache warmup
| Q | A
| ------------- | ---
| Branch? | 6.1
| Bug fix? | yes
| New feature? | no
| Deprecations? | no
| Tickets | -
| License | MIT
| Doc PR | -
In my project, the template directory contains all the frontend assets (CSS, JS and images), this is a choice to locate all component files in the same directories. But the asset files are compiled as if they were twig template, which is a waste of time and storage.
```
front/
├─ components/
│ ├─ video/
│ │ ├─ templates/
│ │ │ ├─ video.html.twig
│ │ ├─ styles/
│ │ │ ├─ video.css
│ │ ├─ scripts/
│ │ │ ├─ video.js
```
~This patch limit warmup to `*.twig` files.~
This PR adds an option to restrict file pattern, for cache warmup and lint.
```yaml
twig:
file_name_pattern: "*.twig"
```
| | Before | After |
|------------------|--------|-------|
| Time to generate | 25s | 9s |
| Storage | 80MB | 26MB |
| Number of files | 4800 | 1500 |
The filter on `*.twig` files is already in the `lint:twig` command.
Note: If a non-twig template is included in a template (ex: to inline CSS), the `source()` function must be used ; the cache is not used in this case.
Commits
-------
4de7a0227b Use an option for twig file names in cache warmer and linter1 file changed
+4
-2
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
39 | 39 | | |
40 | 40 | | |
41 | 41 | | |
| 42 | + | |
42 | 43 | | |
43 | 44 | | |
44 | 45 | | |
45 | | - | |
| 46 | + | |
46 | 47 | | |
47 | 48 | | |
48 | 49 | | |
49 | 50 | | |
| 51 | + | |
50 | 52 | | |
51 | 53 | | |
52 | 54 | | |
| |||
146 | 148 | | |
147 | 149 | | |
148 | 150 | | |
149 | | - | |
| 151 | + | |
150 | 152 | | |
151 | 153 | | |
152 | 154 | | |
| |||
0 commit comments