nonzzz / vite-plugin-compression

vite plugin. compress your bundle file.
MIT License
171 stars 10 forks source link

When the 'filename' is set to the original file name '[path][base]' and 'deleteOriginalAssets' is used simultaneously, it will result in the compressed file being deleted as well. #34

Closed yogingliu closed 1 year ago

yogingliu commented 1 year ago

Bug report 🐞

import viteCompression from 'vite-plugin-compression2'
viteCompression({
    algorithm: 'gzip',
    include: /\.(js|svg)$/i,    
    deleteOriginalAssets: true,
    filename: '[path][base]',
  })

Version & Environment

{
  "devDependencies": {
    "vite": "^4.3.9",
    "vite-plugin-compression2": "^0.10.1",
  }
}

Expection

Original file should be deleted, and the .gz extension should be removed (thus resulting in the same file name as the original).

Actual results (or Errors)

All compressed files and their original files have been deleted.

I suspect it is an issue with the execution order. It is possible that the .gz files were deleted along with the original files based on their original file names after the new names were generated.

nonzzz commented 1 year ago

In 0.10.2 this problem has been fixed. I'm not sure what happened in your local env. I think may we check the plugin version in your local ?

nonzzz commented 1 year ago

And your option filename":'[path][base]' is meaning the compressed result name isn't the original file name : )

nonzzz commented 1 year ago

details see https://github.com/nonzzz/vite-plugin-compression/issues/31

yogingliu commented 1 year ago

Thx for your reply @nonzzz , After upgrading to version 0.10.2, I have fixed the issue.