@averjs/nuxt-compression
TypeScript icon, indicating that this package has built-in type declarations

1.2.2 • Public • Published

Compression module for Nuxt 3

npm version npm downloads ci workflow

This is an unofficial compression module for Nuxt 3. Currently it only works with vite. It uses vite-plugin-compression to generate the compressed files. To make this work and serve those files, this plugin modifies the internal code of the unjs/nitro package. There is already an issue for an official way to implement some kind of compression which you can check out here.

Setup

yarn install -D @averjs/nuxt-compression
pnpm add -D @averjs/nuxt-compression

Usage

export default defineNuxtConfig({
  buildModules: ['@averjs/nuxt-compression'],
  'compression': {
    // options
  },
});

Options

viteCompression

  • default -
{
  algorithm: 'brotliCompress',
  filter: /\.(js|mjs|json|css|html)$/i
}

Options for the vite-plugin-compression plugin

maxAge

  • default - 60 * 60 * 24 * 365

Set the maxAge for the Cache-Control Header. Can either be a number or a filter function which accepts the asset path and should return a number. Be aware, if you use cacheControl alongside maxAge, it is getting ignored.

cacheControl

  • default - undefined

Set Cache-Control Header. Can either be a string or a filter function which accespts the asset path and should return a valid Cache-Control Header string. This option has more weight than maxAge and overwrites it. You can head to MDN to see all the available options.

Development

  • Run pnpm dev:prepare to generate type stubs.
  • Use pnpm dev to start playground in development mode.

Readme

Keywords

none

Package Sidebar

Install

npm i @averjs/nuxt-compression

Weekly Downloads

124

Version

1.2.2

License

MIT

Unpacked Size

9.46 kB

Total Files

7

Last publish

Collaborators

  • fweber
  • thegorilla