vite-plugin-compression icon indicating copy to clipboard operation
vite-plugin-compression copied to clipboard

Completely replace gzipped file extension to just `.js`

Open juanzitelli opened this issue 1 year ago • 1 comments

Ability to Override Output File Extension

Currently, the plugin adds the .gz extension to compressed files by default. However, it would be useful to have the ability to completely override the output file extension to suit specific project requirements.

For example, it would be great to have the option to replace the default .js.gz extension with just .js This would allow for greater flexibility in configuring the plugin and output file naming conventions.

In case of configuring your vite config file to this:

output: {
	entryFileNames: '[name].js',
},

and then your vite compress plugin config to this:

viteCompression({
      algorithm: 'gzip',
      deleteOriginFile: true,
      ext: '.js',
    }),

the resulting files will have .js.js extension. Leaving ext to just an empty string ("") defaults the config to set .gz as the final file extension.

juanzitelli avatar May 04 '23 20:05 juanzitelli