{"id":13782538,"url":"https://github.com/ralscha/parcel-plugin-compress","last_synced_at":"2025-05-11T15:32:34.836Z","repository":{"id":57319001,"uuid":"118913577","full_name":"ralscha/parcel-plugin-compress","owner":"ralscha","description":"Parcel plugin that pre-compresses resources with Brotli and Gzip","archived":true,"fork":false,"pushed_at":"2021-12-24T10:08:52.000Z","size":61,"stargazers_count":51,"open_issues_count":0,"forks_count":8,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-04-19T14:12:25.889Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ralscha.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-01-25T13:03:23.000Z","updated_at":"2024-04-08T16:27:52.000Z","dependencies_parsed_at":"2022-08-25T21:00:47.668Z","dependency_job_id":null,"html_url":"https://github.com/ralscha/parcel-plugin-compress","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ralscha%2Fparcel-plugin-compress","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ralscha%2Fparcel-plugin-compress/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ralscha%2Fparcel-plugin-compress/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ralscha%2Fparcel-plugin-compress/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ralscha","download_url":"https://codeload.github.com/ralscha/parcel-plugin-compress/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253588753,"owners_count":21932319,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-03T18:01:38.752Z","updated_at":"2025-05-11T15:32:34.551Z","avatar_url":"https://github.com/ralscha.png","language":"JavaScript","funding_links":[],"categories":["Plugins"],"sub_categories":["Other"],"readme":"### This is a Parcel 1 plugin. \r\n### Parcel 2 has built-in support for compressing assets: https://parceljs.org/features/production/#compression\r\n\r\n------\r\n\r\nParcel 1 plugin that precompresses all assets in production mode. \r\n\r\nThis plugin utilizes [@gfx/zopfli](https://github.com/gfx/universal-zopfli-js), [node-zopfli-es](https://github.com/jaeh/node-zopfli-es) and [zlib](https://nodejs.org/dist/latest-v13.x/docs/api/zlib.html) for GZip compression\r\nand [zlib](https://nodejs.org/dist/latest-v13.x/docs/api/zlib.html) (Node 11.7.0+) and [brotli](https://www.npmjs.com/package/brotli) for Brotli compression.\r\n\r\n\r\n## Installation\r\n\r\n```\r\nnpm install parcel-plugin-compress -D\r\n```\r\n\r\n\r\n## Usage\r\n\r\nBy default, this plugin doesn't require any extra configuration to get started. If, however, you'd like to be more targeted in how this plugin is applied, you can configure the plugin as needed.\r\n\r\nTo configure, add a file called `.compressrc` in your project's root folder, or add a key in your `package.json` called `compress`. The available options are below, with the defaults.\r\n\r\n```js\r\n{\r\n  // a regular expression to test filenames against\r\n  \"test\": \".\",\r\n  // a number that represents the minimum filesize to compress, in bytes\r\n  \"threshold\": undefined,\r\n  // Concurrency limit for p-queue\r\n  concurrency: 2,\r\n  // configuration options for gzip compression\r\n  \"gzip\": {\r\n    \"enabled\": true,\r\n    \"numiterations\": 15,\r\n    \"blocksplitting\": true,\r\n    \"blocksplittinglast\": false,\r\n    \"blocksplittingmax\": 15,\r\n    // use zlib instead of zopfli if zlib is true\r\n    \"zlib\": false,\r\n    \"zlibLevel\": 9,\r\n    \"zlibMemLevel\": 9\r\n  },\r\n  // configuration options for brotli compress\r\n  \"brotli\": {\r\n    \"enabled\": true,\r\n    \"mode\": 0, // 0 = generic, 1 = text, 2 = font (used in WOFF 2.0)\r\n    \"quality\": 11, // 0 - 11, 11 = best\r\n    \"lgwin\": 24, // 10 - 24    \r\n    \"enable_context_modeling\": true, // disabling decreases compression ratio in favour of decompression speed\r\n    \"lgblock\": undefined, // 16 - 24\r\n    \"nPostfix\": undefined, // 0 - 3\r\n    \"nDirect\": undefined // 0 to (15 \u003c\u003c nPostfix) in steps of (1 \u003c\u003c nPostfix)\r\n  },\r\n  // a flag that changes the behavior of the plugin, by default this option is disabled\r\n  // and the plugin compresses all the files it receives via the Parcel bundle object\r\n  // and match the test regular expression\r\n  //\t\r\n  // if true the plugin compresses all files in the output directory and subdirectories\r\n  // that match the test regular expression\r\n  compressOutput: false\r\n}\r\n```\r\n\r\n\r\n## Browser Support for Brotli\r\n\r\nCurrent versions of the major browsers send `br` in the `Accept-Encoding` header when the request is sent over TLS\r\n\r\nSupport introduced in version ...\r\n\r\n  * Edge 15\r\n  * Firefox 44\r\n  * Chrome 50\r\n  * Safari 11\r\n\r\n\r\n## Server support\r\n\r\nTo take advantage of precompressed resources you need a server that is able to understand the `Accept-Encoding` header and serve files ending with `.gz` and `.br` accordingly.\r\n\r\n#### Nginx \r\nNginx supports Gzip compressed files out of the box with the `gzip_static` directive. \r\n\r\nAdd this to a `http`, `server` or `location` section and Nginx will automatically search for files ending with .gz when the request contains an `Accept-Encoding` header with the value `gzip`. \r\n```\r\ngzip_static  on;  \r\n```\r\nSee the [documentation](http://nginx.org/en/docs/http/ngx_http_gzip_static_module.html) for more information.\r\n\r\nTo enable Brotli support you either \r\n  * build the [ngx_brotli](https://github.com/google/ngx_brotli) from source:          \r\n    https://www.majlovesreg.one/adding-brotli-to-a-built-nginx-instance\r\n  * or install a pre-built Nginx from ppa with the brotli module included:  \r\n    https://gablaxian.com/blog/brotli-compression\r\n  * or use the approach described in this blog post that works without the brotli module:    \r\n    https://siipo.la/blog/poor-mans-brotli-serving-brotli-files-without-nginx-brotli-module\r\n\r\n\r\n#### Apache HTTP\r\nhttps://css-tricks.com/brotli-static-compression/     \r\nhttps://blog.desgrange.net/post/2017/04/10/pre-compression-with-gzip-and-brotli-in-apache.html\r\n\r\n\r\n#### LightSpeed\r\nSupport for Brotli introduced in version [5.2](https://www.litespeedtech.com/products/litespeed-web-server/release-log)\r\n\r\n\r\n\r\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fralscha%2Fparcel-plugin-compress","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fralscha%2Fparcel-plugin-compress","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fralscha%2Fparcel-plugin-compress/lists"}