modern.js icon indicating copy to clipboard operation
modern.js copied to clipboard

[Feature]: Gzip compression for production files

Open YanPes opened this issue 10 months ago • 1 comments

What problem does this feature solve?

This feature request is a follow up on the discussion #6904 .

When using Modern.js server to serve output files directly, it would be beneficial to have a bundler.config option to set the compression of dist files to use gzip. This will enable developers to optimize the browser performance when receiving files dramatically. Although this is possible to be achieved via nginx configurations, etc., I am believe this is a great additional to the feature-stack of a modern full-stack-framework. Also, not all consumers rely on options like nginx to keep a clean footprint.

In the current version, Modern.js can use this compression method for devServer only:

export default defineConfig({
  devServer: {
    // Enable gzip compression in devServer config
    compression: true
  }
})

What does the proposed API look like?

Bundler configuration

// modern.config.ts
export default defineConfig({
  devServer: {
    compression: true
  }
  server: {
    // Enable gzip compression in for production files as well
    compression: true
  }
})

Usage

The configuration should be used when starting the Modern.js server via pnpm run start, pnpm run serve and pnpm run deploy

YanPes avatar Mar 10 '25 12:03 YanPes

PR welcome

YanPes avatar Mar 10 '25 12:03 YanPes