3
3
A plugin to make building with Eleventy and Netlify a joy!
4
4
5
5
### Speed up your builds ⚡
6
- - Caches images generated by [ @11ty/eleventy-img ] ( https://github.com/11ty/eleventy-img ) across builds
7
- - Caches assets fetched by [ @11ty/eleventy-fetch ] ( https://github.com/11ty/eleventy-fetch ) across builds
6
+
7
+ - Caches images generated by
8
+ [ @11ty/eleventy-img ] ( https://github.com/11ty/eleventy-img ) across builds
9
+ - Caches assets fetched by
10
+ [ @11ty/eleventy-fetch ] ( https://github.com/11ty/eleventy-fetch ) across builds
8
11
- Caches any other folders of your choice (optional)
9
12
10
13
## Install
@@ -30,79 +33,86 @@ And add the plugin to your `netlify.toml` file:
30
33
cache_other = []
31
34
```
32
35
33
- Make sure the path for [ ` cache_img ` ] ( #1-cache_img ) is correct. Aand you're done! 🥳
36
+ Make sure the path for [ ` cache_img ` ] ( #1-cache_img ) is correct. Aand you're done!
37
+ 🥳
34
38
35
- You can read Netlify's documentation about Plugins here: https://docs.netlify.com/configure-builds/build-plugins/
39
+ You can read Netlify's documentation about Plugins here:
40
+ https://docs.netlify.com/configure-builds/build-plugins/
36
41
37
- ** Note** : If your builds are failing, the version of Node
38
- you're using is probably not supported by Netlify.
39
- Try Node v16.x.x.
40
- See the [ FAQs section] ( #my-builds-are-failing ) for more info.
42
+ ** Note** : If your builds are failing, the version of Node you're using is
43
+ probably not supported by Netlify. Try Node v16.x.x. See the
44
+ [ FAQs section] ( #my-builds-are-failing ) for more info.
41
45
42
46
## Documentation
43
47
44
- ### 1. ` cache_img `
48
+ ### 1. ` cache_img `
45
49
46
- Type: ` String ` or ` Array of Strings `
47
- Default: ` 'img' ` (relative to the publish directory)
50
+ Type: ` String ` or ` Array of Strings `
51
+ Default: ` 'img' ` (relative to the publish directory)
48
52
49
- Path to the folder(s) in which files generated by ` @11ty/eleventy-img ` are stored,
50
- relative to the publish directory. Can be a String or an array of Strings.
53
+ Path to the folder(s) in which files generated by ` @11ty/eleventy-img ` are
54
+ stored, relative to the publish directory. Can be a String or an array of
55
+ Strings.
51
56
52
57
If set to ` false ` , files generated by ` @11ty/eleventy-img ` are not saved in
53
58
Netlify cache.
54
59
55
60
### 2. ` cache_img_httpHeader `
56
61
57
- Type: ` Boolean `
58
- Default: ` false `
62
+ Type: ` Boolean `
63
+ Default: ` false `
59
64
60
65
If set to ` true ` , files generated by ` @11ty/eleventy-img ` will be served with
61
66
http header ` cache-control: public, max-age=31536000, immutable ` .
62
67
63
68
Files generated by ` eleventy_img ` have a hash calculated using file content and
64
69
[ Sharp plugin options] ( https://www.11ty.dev/docs/plugins/image/#advanced-control-of-sharp-image-processor )
65
- in their name by default ([ starting from #116 ] ( https://github.com/11ty/eleventy-img/pull/116 ) ),
66
- so you can cache them indefinitely. Don't use this if you're using remote images.
70
+ in their name by default
71
+ ([ starting from #116 ] ( https://github.com/11ty/eleventy-img/pull/116 ) ), so you
72
+ can cache them indefinitely. Don't use this if you're using remote images.
67
73
68
74
:warning : ** Caution** :
75
+
69
76
- If you are using remote images, this option should be ` false ` (default).
70
- - If you are using [ custom filenames] ( https://www.11ty.dev/docs/plugins/image/#custom-filenames-new-in-image-0.4.0 )
71
- that don't include a hash, this option should be ` false ` (default).
77
+ - If you are using
78
+ [ custom filenames] ( https://www.11ty.dev/docs/plugins/image/#custom-filenames-new-in-image-0.4.0 )
79
+ that don't include a hash, this option should be ` false ` (default).
72
80
73
81
### 3. ` cache_assets `
74
82
75
83
Type: ` String ` or ` Array of Strings `
76
- Default: ` '../.cache' ` (relative to the publish directory)
84
+ Default: ` '../.cache' ` (relative to the publish directory)
77
85
78
- Path to the folder(s) in which remote assets fetched by [ @ 11ty/eleventy-fetch ] ( https://github.com/11ty/eleventy-fetch )
79
- are cached, relative to publish directory. Can be a String or an array of
80
- Strings.
86
+ Path to the folder(s) in which remote assets fetched by
87
+ [ @ 11ty/eleventy-fetch ] ( https://github.com/11ty/eleventy-fetch ) are cached,
88
+ relative to publish directory. Can be a String or an array of Strings.
81
89
82
- If set to ` false ` , assets fetched by ` @11ty/eleventy-fetch ` are not saved
83
- in Netlify cache.
90
+ If set to ` false ` , assets fetched by ` @11ty/eleventy-fetch ` are not saved in
91
+ Netlify cache.
84
92
85
93
### 4. ` cache_other `
86
94
87
95
Type: ` String ` or ` Array of Strings `
88
- Default: ` [] ` (relative to the publish directory)
96
+ Default: ` [] ` (relative to the publish directory)
89
97
90
- Paths to any other folder(s) you'd like to cache across Netlify builds. If these folders
91
- exist before restoring Nelify cache, their content will be merged and overwritten
92
- with content from the cached folders.
98
+ Paths to any other folder(s) you'd like to cache across Netlify builds. If these
99
+ folders exist before restoring Nelify cache, their content will be merged and
100
+ overwritten with content from the cached folders.
93
101
94
102
## FAQs
103
+
95
104
### I ` rimraf ` my ` _site ` on every build
96
105
97
- If your images are written to ` _site/img ` (default),
98
- use ` rimraf '_site/!(img)' ` .
106
+ If your images are written to ` _site/img ` (default), use
107
+ ` rimraf '_site/!(img)' ` .
99
108
100
- If they are in a subdirectory, say ` _site/assets/images ` ,
101
- use ` rimraf '_site/!(assets)' '_site/assets/!(images)' ` .
109
+ If they are in a subdirectory, say ` _site/assets/images ` , use
110
+ ` rimraf '_site/!(assets)' '_site/assets/!(images)' ` .
102
111
103
112
### My builds are failing
104
113
105
114
If your build fails with
115
+
106
116
``` bash
107
117
11:37:10 AM: Uncaught exception, the process will now terminate…
108
118
11:37:10 AM: Error: Unable to deserialize cloned data due to invalid or unsupported version.
@@ -120,34 +130,40 @@ echo "16" > .nvmrc
120
130
```
121
131
122
132
More info about this error:
133
+
123
134
- https://answers.netlify.com/t/netlify-build-cache-error/78115/4
124
135
- https://answers.netlify.com/t/build-failing-after-upgrade-to-node-18/75774
125
136
126
137
See this guide for more ways to set Node versions:
127
138
https://docs.netlify.com/configure-builds/manage-dependencies/
128
139
129
140
### Are there any Benchmarks?
141
+
130
142
Yes!
131
143
132
- The speed-up, ofcourse, depends on how many images your website has,
133
- but here is a benchmark I used when developing this plugin:
144
+ The speed-up, ofcourse, depends on how many images your website has, but here is
145
+ a benchmark I used when developing this plugin:
134
146
135
- | Run | No cache persistence | With cache persistence |
136
- | ----------------------- | ---------------------- | -------------------------- |
137
- | 1st run (empty cache) | 11.74 seconds | 11.52 seconds |
138
- | 2nd run (filled cache)| 11.32 seconds | 131.82 ** milliseconds** |
147
+ | Run | No cache persistence | With cache persistence |
148
+ | ---------------------- | -------------------- | ----------------------- |
149
+ | 1st run (empty cache) | 11.74 seconds | 11.52 seconds |
150
+ | 2nd run (filled cache) | 11.32 seconds | 131.82 ** milliseconds** |
139
151
140
152
[ Read more] ( https://github.com/11ty/eleventy-img/pull/116#issuecomment-882870369 )
141
153
142
154
## Recommended Netlify plugins
155
+
143
156
- [ Subfont] ( https://github.com/munter/netlify-plugin-subfont )
144
157
- [ Inline Critical CSS] ( https://github.com/Tom-Bonnike/netlify-plugin-inline-critical-css#readme )
145
158
146
159
## Bug Reports, Feature Requests, and Ideas
147
- Please [ create an issue] ( https://github.com/zeroby0/netlify-plugin-11ty/issues/new/ ) :)
160
+
161
+ Please
162
+ [ create an issue] ( https://github.com/zeroby0/netlify-plugin-11ty/issues/new/ ) :)
148
163
149
164
## License
165
+
150
166
** MIT**
151
167
152
- If you need this repository with a different License,
153
- please [ create an issue] ( https://github.com/zeroby0/netlify-plugin-11ty/issues/new/ ) .
168
+ If you need this repository with a different License, please
169
+ [ create an issue] ( https://github.com/zeroby0/netlify-plugin-11ty/issues/new/ ) .
0 commit comments