serve icon indicating copy to clipboard operation
serve copied to clipboard

Ability to serve `.html.gz`, `.js.gz` `.json.gz` etc.

Open hybridherbst opened this issue 1 year ago • 2 comments

Description

In #460, compressing files on serve was introduced.

However, it looks like serve still can't serve already compressed files. (e.g. result of viteCompression() or other commonly used plugins)

Would it be possible to add that?

Why

Testing full deployments of already prezipped files that the server just unpacks on serve

Alternatives

Locally testing without gzip and not really being sure if the gzipped version also works

hybridherbst avatar Jul 23 '24 17:07 hybridherbst

I think sirv does support .gz and .br file endings today, see: https://www.npmjs.com/package/sirv#optsgzip https://www.npmjs.com/package/sirv#optsbrotli

khromov avatar Jul 29 '24 11:07 khromov

Just add the right headers to your serve.json file:

{
  "headers": [
    {
      "source": "**/*.gz",
      "headers": [
        {
          "key": "Content-Encoding",
          "value": "gzip"
        }
      ]
    }
  ]
}

legowerewolf avatar May 06 '25 18:05 legowerewolf