You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
docs: precompress array rules and social media crawlers (#502)
* docs: precompress array rules and social media crawlers
Signed-off-by: David Dal Busco <david.dalbusco@outlook.com>
* 📄 Update LLMs.txt snapshot for PR review
---------
Signed-off-by: David Dal Busco <david.dalbusco@outlook.com>
Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com>
Copy file name to clipboardExpand all lines: .llms-snapshots/llms-full.txt
+47-11Lines changed: 47 additions & 11 deletions
Original file line number
Diff line number
Diff line change
@@ -1804,7 +1804,7 @@ This `source` attribute works similarly to Git's `.gitignore`, and you can speci
1804
1804
1805
1805
### GZIP
1806
1806
1807
-
When deploying your application, the CLI automatically searches for JavaScript (js), ES Module (mjs), CSS (css) and HTML (html) files in the `source` folder to optimize them using Gzip compression. This improves the performance of your app when it is served on the web.
1807
+
When deploying your application, the CLI automatically searches for files matching the pattern `**/*.+(css|js|mjs|html)` in the `source` folder to optimize them using Gzip compression. This improves the performance of your app when it is served on the web.
1808
1808
1809
1809
By default, precompression stores **both** the original and compressed versions in Storage.
1810
1810
@@ -1814,7 +1814,7 @@ You can disable it entirely or customize which files are precompressed, whether
1814
1814
1815
1815
If you change the precompress configuration and your project has already been deployed, run `juno clear` before redeploying to ensure you change is applied.
1816
1816
1817
-
## Disable precompression
1817
+
#### Disable precompression
1818
1818
1819
1819
Set the `precompress` option to `false` in your configuration:
The `mode` option controls what happens to the original files after compression:
1840
1840
1841
1841
* `"both"` — upload both the original and the compressed version. _(default)_
1842
1842
* `"replace"` — upload only the compressed version and serve it with the appropriate `Content-Encoding` header.
1843
1843
1844
+
**Warning:**
1845
+
1846
+
If you use `replace` for HTML, some social media crawlers (e.g. Twitter, LinkedIn) may not be able to fetch your pages correctly, resulting in missing or broken social previews.
1847
+
1848
+
To avoid this, instead of providing a single precompression rule, it's recommended to fine-tune the behavior using an **array of rules** (([see below](#use-multiple-rules))).
In some cases, particularly when using `mode: replace`, you may want to apply different precompression strategies depending on the file type. For example, using replace for JavaScript and CSS files, but doing so for HTML can break social media previews.
1871
+
1872
+
To handle this, the precompress option also accepts an array of rules:
When deploying, the CLI automatically maps the encoding type based on the file extension. The encoding information is then used in the satellite to provide the appropriate HTTP response header `Content-Encoding`.
Usage: juno functions upgrade [options]Options: --cdn Select a previously published WASM file from the CDN (interactive). --cdn-path Use a specific published WASM file from the CDN. --clear-chunks Clear any previously uploaded WASM chunks (applies if the WASM size is greater than 2MB). --no-snapshot Skip creating a snapshot before upgrading. -r, --reset Reset to the initial state. -s, --src A path to a specific local gzipped WASM file to publish. -h, --help Output usage information.Notes:- If no option is provided, the default local build output will be used.- If --src is specified, it takes precedence over any CDN options.- Use --cdn to interactively select from recent published releases.
7745
+
Usage: juno functions upgrade [options]Options: --cdn Select a previously published WASM file from the CDN (interactive). --cdn-path Use a specific published WASM file from the CDN. -s, --src A path to a specific local gzipped WASM file to publish. --clear-chunks Clear any previously uploaded WASM chunks (applies if the WASM size is greater than 2MB). --no-snapshot Skip creating a snapshot before upgrading. -r, --reset Reset to the initial state. -m, --mode Choose which environment to use (production, staging, development). Defaults to production if omitted. -p, --profile Specify an optional profile to use (e.g. personal, team). Useful when managing multiple Mission Controls. --container-url Override a custom container URL. If not provided, defaults to production or the local container in development mode. --console-url Specify a custom URL to access the developer Console. -h, --help Output usage information.Notes:- If no option is provided, the default local build output will be used.- If --src is specified, it takes precedence over any CDN options.- Use --cdn to interactively select from recent published releases.
When deploying your application, the CLI automatically searches for JavaScript (js), ES Module (mjs), CSS (css) and HTML (html) files in the `source` folder to optimize them using Gzip compression. This improves the performance of your app when it is served on the web.
7926
+
When deploying your application, the CLI automatically searches for files matching the pattern `**/*.+(css|js|mjs|html)` in the `source` folder to optimize them using Gzip compression. This improves the performance of your app when it is served on the web.
7909
7927
7910
7928
By default, precompression stores **both** the original and compressed versions in Storage.
7911
7929
@@ -7915,7 +7933,7 @@ You can disable it entirely or customize which files are precompressed, whether
7915
7933
7916
7934
If you change the precompress configuration and your project has already been deployed, run `juno clear` before redeploying to ensure you change is applied.
7917
7935
7918
-
## Disable precompression
7936
+
#### Disable precompression
7919
7937
7920
7938
Set the `precompress` option to `false` in your configuration:
The `mode` option controls what happens to the original files after compression:
7941
7959
7942
7960
* `"both"` — upload both the original and the compressed version. _(default)_
7943
7961
* `"replace"` — upload only the compressed version and serve it with the appropriate `Content-Encoding` header.
7944
7962
7963
+
**Warning:**
7964
+
7965
+
If you use `replace` for HTML, some social media crawlers (e.g. Twitter, LinkedIn) may not be able to fetch your pages correctly, resulting in missing or broken social previews.
7966
+
7967
+
To avoid this, instead of providing a single precompression rule, it's recommended to fine-tune the behavior using an **array of rules** (([see below](#use-multiple-rules))).
In some cases, particularly when using `mode: replace`, you may want to apply different precompression strategies depending on the file type. For example, using replace for JavaScript and CSS files, but doing so for HTML can break social media previews.
7990
+
7991
+
To handle this, the precompress option also accepts an array of rules:
When deploying, the CLI automatically maps the encoding type based on the file extension. The encoding information is then used in the satellite to provide the appropriate HTTP response header `Content-Encoding`.
Copy file name to clipboardExpand all lines: docs/build/components/precompress.mdx
+44-5Lines changed: 44 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,4 +1,4 @@
1
-
When deploying your application, the CLI automatically searches for JavaScript (js), ES Module (mjs), CSS (css) and HTML (html) files in the `source` folder to optimize them using Gzip compression. This improves the performance of your app when it is served on the web.
1
+
When deploying your application, the CLI automatically searches for files matching the pattern `**/*.+(css|js|mjs|html)` in the `source` folder to optimize them using Gzip compression. This improves the performance of your app when it is served on the web.
2
2
3
3
By default, precompression stores **both** the original and compressed versions in Storage.
4
4
@@ -10,7 +10,7 @@ If you change the precompress configuration and your project has already been de
10
10
11
11
:::
12
12
13
-
## Disable precompression
13
+
####Disable precompression
14
14
15
15
Set the `precompress` option to `false` in your configuration:
16
16
@@ -28,7 +28,7 @@ export default defineConfig({
28
28
});
29
29
```
30
30
31
-
## Customize the file matching pattern
31
+
####Customize the file matching pattern
32
32
33
33
If you want to customize the default pattern `**/*.+(css|js|mjs|html)` to better suit your needs, you can specify your own pattern. For example:
34
34
@@ -48,13 +48,21 @@ export default defineConfig({
48
48
});
49
49
```
50
50
51
-
## Decide what happens to original files
51
+
####Decide what happens to original files
52
52
53
53
The `mode` option controls what happens to the original files after compression:
54
54
55
55
-`"both"` — upload both the original and the compressed version. _(default)_
56
56
-`"replace"` — upload only the compressed version and serve it with the appropriate `Content-Encoding` header.
57
57
58
+
:::warning
59
+
60
+
If you use `replace` for HTML, some social media crawlers (e.g. Twitter, LinkedIn) may not be able to fetch your pages correctly, resulting in missing or broken social previews.
61
+
62
+
To avoid this, instead of providing a single precompression rule, it's recommended to fine-tune the behavior using an **array of rules** ([see below](#use-multiple-rules)).
63
+
64
+
:::
65
+
58
66
```javascript title="juno.config.js"
59
67
import { defineConfig } from"@junobuild/config";
60
68
@@ -71,7 +79,7 @@ export default defineConfig({
71
79
});
72
80
```
73
81
74
-
## Choose the compression algorithm
82
+
####Choose the compression algorithm
75
83
76
84
By default, precompression uses **Gzip** (`algorithm: "gzip"`) because it offers a good balance between compression speed, compatibility, and size.
77
85
@@ -92,3 +100,34 @@ export default defineConfig({
92
100
}
93
101
});
94
102
```
103
+
104
+
#### Use multiple rules
105
+
106
+
In some cases, particularly when using `mode: replace`, you may want to apply different precompression strategies depending on the file type. For example, using replace for JavaScript and CSS files, but doing so for HTML can break social media previews.
107
+
108
+
To handle this, the precompress option also accepts an array of rules:
0 commit comments