diff --git a/.llms-snapshots/llms-full.txt b/.llms-snapshots/llms-full.txt index 27333f40..19c41de1 100644 --- a/.llms-snapshots/llms-full.txt +++ b/.llms-snapshots/llms-full.txt @@ -1675,7 +1675,7 @@ You can customize your hosting environment to fit your needs, including: * Serve a customized 404 page. ([Learn how.](#customize-a-404not-found-page)) * Set up `redirects` for pages that you've moved or deleted. ([Learn how.](#redirects)) * Set up `rewrites`. ([Learn how.](#rewrites)) -* Tweak `gzip` compression for best performance. ([Learn how.](#gzip)) +* Customize file `compression` for optimal performance. ([Learn how.](#precompress)) * Customize the `encoding` behavior of your files. ([Learn how.](#encoding-types)) * Allow your project to be embedded as an `iframe`. ([Learn how.](#iframe)) * Customize `assertions` to modify the default verification behavior of the CLI. ([Learn how.](#assertions)) @@ -1804,24 +1804,59 @@ This `source` attribute works similarly to Git's `.gitignore`, and you can speci ### GZIP -When deploying your application, the CLI automatically searches for JavaScript (js), ES Module (mjs), and CSS (css) files in the `source` folder and optimizes them using Gzip compression. This is useful because neither the protocol nor a satellite can compress these files, ensuring the best web performance. +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. -If you wish to customize this behavior, you have the option to disable it or provide a different file matching pattern using glob syntax. +By default, precompression stores **both** the original and compressed versions in Storage. -To opt-out of Gzip compression, simply set the `gzip` option to `false` in your configuration: +You can disable it entirely or customize which files are precompressed, whether to keep originals, and which compression algorithm to use. + +**Note:** + +If you change the precompress configuration and your project has already been deployed, run `juno clear` before redeploying to ensure you change is applied. + +## Disable precompression + +Set the `precompress` option to `false` in your configuration: juno.config.js ``` -import { defineConfig } from "@junobuild/config";export default defineConfig({ satellite: { ids: { production: "qsgjb-riaaa-aaaaa-aaaga-cai" }, source: "dist", gzip: false }}); +import { defineConfig } from "@junobuild/config";export default defineConfig({ satellite: { ids: { production: "qsgjb-riaaa-aaaaa-aaaga-cai" }, source: "dist", precompress: false }}); ``` +## Customize the file matching pattern + 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: juno.config.js ``` -import { defineConfig } from "@junobuild/config";export default defineConfig({ satellite: { ids: { production: "qsgjb-riaaa-aaaaa-aaaga-cai" }, source: "dist", gzip: "**/*.jpg" }}); +import { defineConfig } from "@junobuild/config";export default defineConfig({ satellite: { ids: { production: "qsgjb-riaaa-aaaaa-aaaga-cai" }, source: "dist", precompress: { pattern: "**/*.jpg" // precompress JPEG files only } }}); +``` + +## Decide what happens to original files + +The `mode` option controls what happens to the original files after compression: + +* `"both"` — upload both the original and the compressed version. _(default)_ +* `"replace"` — upload only the compressed version and serve it with the appropriate `Content-Encoding` header. + +juno.config.js + +``` +import { defineConfig } from "@junobuild/config";export default defineConfig({ satellite: { ids: { production: "qsgjb-riaaa-aaaaa-aaaga-cai" }, source: "dist", precompress: { mode: "replace" } }}); +``` + +## Choose the compression algorithm + +By default, precompression uses **Gzip** (`algorithm: "gzip"`) because it offers a good balance between compression speed, compatibility, and size. + +You can switch to **Brotli** (`algorithm: "brotli"`) for potentially smaller files, especially for text-based assets such as those compressed by default like HTML, CSS, and JavaScript. + +juno.config.js + +``` +import { defineConfig } from "@junobuild/config";export default defineConfig({ satellite: { ids: { production: "qsgjb-riaaa-aaaaa-aaaga-cai" }, source: "dist", precompress: { algorithm: "brotli" } }}); ``` ### Encoding types @@ -7858,26 +7893,61 @@ juno.config.js import { defineConfig } from "@junobuild/config";export default defineConfig({ satellite: { ids: { production: "qsgjb-riaaa-aaaaa-aaaga-cai" }, source: "dist", ignore: ["**/*.txt", ".tmp/"] }}); ``` -### GZIP +### Precompress -When deploying your application, the CLI automatically searches for JavaScript (js), ES Module (mjs), and CSS (css) files in the `source` folder and optimizes them using Gzip compression. This is useful because neither the protocol nor a satellite can compress these files, ensuring the best web performance. +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. -If you wish to customize this behavior, you have the option to disable it or provide a different file matching pattern using glob syntax. +By default, precompression stores **both** the original and compressed versions in Storage. -To opt-out of Gzip compression, simply set the `gzip` option to `false` in your configuration: +You can disable it entirely or customize which files are precompressed, whether to keep originals, and which compression algorithm to use. + +**Note:** + +If you change the precompress configuration and your project has already been deployed, run `juno clear` before redeploying to ensure you change is applied. + +## Disable precompression + +Set the `precompress` option to `false` in your configuration: juno.config.js ``` -import { defineConfig } from "@junobuild/config";export default defineConfig({ satellite: { ids: { production: "qsgjb-riaaa-aaaaa-aaaga-cai" }, source: "dist", gzip: false }}); +import { defineConfig } from "@junobuild/config";export default defineConfig({ satellite: { ids: { production: "qsgjb-riaaa-aaaaa-aaaga-cai" }, source: "dist", precompress: false }}); ``` +## Customize the file matching pattern + 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: juno.config.js ``` -import { defineConfig } from "@junobuild/config";export default defineConfig({ satellite: { ids: { production: "qsgjb-riaaa-aaaaa-aaaga-cai" }, source: "dist", gzip: "**/*.jpg" }}); +import { defineConfig } from "@junobuild/config";export default defineConfig({ satellite: { ids: { production: "qsgjb-riaaa-aaaaa-aaaga-cai" }, source: "dist", precompress: { pattern: "**/*.jpg" // precompress JPEG files only } }}); +``` + +## Decide what happens to original files + +The `mode` option controls what happens to the original files after compression: + +* `"both"` — upload both the original and the compressed version. _(default)_ +* `"replace"` — upload only the compressed version and serve it with the appropriate `Content-Encoding` header. + +juno.config.js + +``` +import { defineConfig } from "@junobuild/config";export default defineConfig({ satellite: { ids: { production: "qsgjb-riaaa-aaaaa-aaaga-cai" }, source: "dist", precompress: { mode: "replace" } }}); +``` + +## Choose the compression algorithm + +By default, precompression uses **Gzip** (`algorithm: "gzip"`) because it offers a good balance between compression speed, compatibility, and size. + +You can switch to **Brotli** (`algorithm: "brotli"`) for potentially smaller files, especially for text-based assets such as those compressed by default like HTML, CSS, and JavaScript. + +juno.config.js + +``` +import { defineConfig } from "@junobuild/config";export default defineConfig({ satellite: { ids: { production: "qsgjb-riaaa-aaaaa-aaaga-cai" }, source: "dist", precompress: { algorithm: "brotli" } }}); ``` ### Encoding diff --git a/docs/build/components/gzip.mdx b/docs/build/components/gzip.mdx deleted file mode 100644 index a215033f..00000000 --- a/docs/build/components/gzip.mdx +++ /dev/null @@ -1,35 +0,0 @@ -When deploying your application, the CLI automatically searches for JavaScript (js), ES Module (mjs), and CSS (css) files in the `source` folder and optimizes them using Gzip compression. This is useful because neither the protocol nor a satellite can compress these files, ensuring the best web performance. - -If you wish to customize this behavior, you have the option to disable it or provide a different file matching pattern using glob syntax. - -To opt-out of Gzip compression, simply set the `gzip` option to `false` in your configuration: - -```javascript title="juno.config.js" -import { defineConfig } from "@junobuild/config"; - -export default defineConfig({ - satellite: { - ids: { - production: "qsgjb-riaaa-aaaaa-aaaga-cai" - }, - source: "dist", - gzip: false - } -}); -``` - -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: - -```javascript title="juno.config.js" -import { defineConfig } from "@junobuild/config"; - -export default defineConfig({ - satellite: { - ids: { - production: "qsgjb-riaaa-aaaaa-aaaga-cai" - }, - source: "dist", - gzip: "**/*.jpg" - } -}); -``` diff --git a/docs/build/components/precompress.mdx b/docs/build/components/precompress.mdx new file mode 100644 index 00000000..09c57cc1 --- /dev/null +++ b/docs/build/components/precompress.mdx @@ -0,0 +1,94 @@ +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. + +By default, precompression stores **both** the original and compressed versions in Storage. + +You can disable it entirely or customize which files are precompressed, whether to keep originals, and which compression algorithm to use. + +:::note + +If you change the precompress configuration and your project has already been deployed, run `juno clear` before redeploying to ensure you change is applied. + +::: + +## Disable precompression + +Set the `precompress` option to `false` in your configuration: + +```javascript title="juno.config.js" +import { defineConfig } from "@junobuild/config"; + +export default defineConfig({ + satellite: { + ids: { + production: "qsgjb-riaaa-aaaaa-aaaga-cai" + }, + source: "dist", + precompress: false + } +}); +``` + +## Customize the file matching pattern + +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: + +```javascript title="juno.config.js" +import { defineConfig } from "@junobuild/config"; + +export default defineConfig({ + satellite: { + ids: { + production: "qsgjb-riaaa-aaaaa-aaaga-cai" + }, + source: "dist", + precompress: { + pattern: "**/*.jpg" // precompress JPEG files only + } + } +}); +``` + +## Decide what happens to original files + +The `mode` option controls what happens to the original files after compression: + +- `"both"` — upload both the original and the compressed version. _(default)_ +- `"replace"` — upload only the compressed version and serve it with the appropriate `Content-Encoding` header. + +```javascript title="juno.config.js" +import { defineConfig } from "@junobuild/config"; + +export default defineConfig({ + satellite: { + ids: { + production: "qsgjb-riaaa-aaaaa-aaaga-cai" + }, + source: "dist", + precompress: { + mode: "replace" + } + } +}); +``` + +## Choose the compression algorithm + +By default, precompression uses **Gzip** (`algorithm: "gzip"`) because it offers a good balance between compression speed, compatibility, and size. + +You can switch to **Brotli** (`algorithm: "brotli"`) for potentially smaller files, especially for text-based assets such as those compressed by default like HTML, CSS, and JavaScript. + +```javascript title="juno.config.js" +import { defineConfig } from "@junobuild/config"; + +export default defineConfig({ + satellite: { + ids: { + production: "qsgjb-riaaa-aaaaa-aaaga-cai" + }, + source: "dist", + precompress: { + algorithm: "brotli" + } + } +}); +``` diff --git a/docs/build/hosting/configuration.mdx b/docs/build/hosting/configuration.mdx index b46e7d4d..df2dda8a 100644 --- a/docs/build/hosting/configuration.mdx +++ b/docs/build/hosting/configuration.mdx @@ -8,7 +8,7 @@ You can customize your hosting environment to fit your needs, including: - Serve a customized 404 page. [Learn how.](#customize-a-404not-found-page) - Set up `redirects` for pages that you've moved or deleted. [Learn how.](#redirects) - Set up `rewrites`. [Learn how.](#rewrites) -- Tweak `gzip` compression for best performance. [Learn how.](#gzip) +- Customize file `compression` for optimal performance. [Learn how.](#precompress) - Customize the `encoding` behavior of your files. [Learn how.](#encoding-types) - Allow your project to be embedded as an `iframe`. [Learn how.](#iframe) - Customize `assertions` to modify the default verification behavior of the CLI. [Learn how.](#assertions) @@ -69,9 +69,9 @@ import Rewrites from "../components/rewrites.mdx"; ### GZIP -import Gzip from "../components/gzip.mdx"; +import Precompress from "../components/precompress.mdx"; - + ### Encoding types diff --git a/docs/reference/configuration.mdx b/docs/reference/configuration.mdx index 9d70ff3f..cc874b13 100644 --- a/docs/reference/configuration.mdx +++ b/docs/reference/configuration.mdx @@ -73,11 +73,11 @@ import IgnoreFiles from "../build/components/ignore-files.mdx"; -### GZIP +### Precompress -import Gzip from "../build/components/gzip.mdx"; +import Precompress from "../build/components/precompress.mdx"; - + ### Encoding