🚀 Big News:Socket Has Acquired Secure Annex.Learn More →
Socket
Book a DemoSign in
Socket

@averjs/nuxt-compression

Package Overview
Dependencies
Maintainers
2
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@averjs/nuxt-compression

[![npm version][npm-version-src]][npm-version-href] [![npm downloads][npm-downloads-src]][npm-downloads-href] ![ci workflow](https://github.com/exreplay/nuxt-compression/actions/workflows/ci.yml/badge.svg)

latest
npmnpm
Version
1.2.2
Version published
Weekly downloads
172
44.54%
Maintainers
2
Weekly downloads
 
Created
Source

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.

FAQs

Package last updated on 27 Aug 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts