nonzzz / vite-plugin-compression

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

Error: ENOENT: no such file or directory #39

Closed Flyfish233 closed 1 year ago

Flyfish233 commented 1 year ago

Bug report 🐞

With deleteOriginalAssets: true it seems to delete the assets file early and create 0kb br files.

Generate br files with 0kb:

ChangeLog-3faf1141.js.br : 0kb
ChangeLog-3faf1141.js.gz : 498 bytes
ChangeLog-legacy-d61b07c3.js.br : 0kb
...
Settings-legacy-a607e528.js.br : 0kb

Version & Environment

    "vue": "^3.3.4",
    "vue-i18n": "^9.2.2",
    "vue-meta": "^3.0.0-alpha.2",
    "vue-router": "^4.2.4",
    "vuetify": "^3.3.9",
    "prettier": "^3.0.0",
    "sass": "^1.63.6",
    "vite": "^4.4.4",
    "vite-plugin-compression2": "^0.10.2",
    "@rollup/plugin-terser": "^0.4.3",
    "@vitejs/plugin-legacy": "^4.1.0",
    "@vitejs/plugin-vue": "^4.2.3",
    "vite-plugin-prettier": "^0.0.5",
    "vite-plugin-vuetify": "^1.0.2"
plugins: [
        vue(),
        vuetify({ autoImport: true }),
        legacy({
            targets: ['chrome 61']
        }),
        terser(),
        viteCompression({
            include: [/.js$/, /.css$/]
        }),
        viteCompression({
            algorithm: 'brotliCompress',
            include: [/.js$/, /.css$/],
            exclude: [/\.(br)$/, /\.(gz)$/],
            deleteOriginalAssets: true
        })
    ]

Expection

Change to deleteOriginalAssets: false.

Works fine, then just delete all js and css files manually instead of deleting them all automatically.

Actual results (or Errors)

βœ“ built in 18.82s
node:internal/process/promises:288
            triggerUncaughtException(err, true /* fromPromise */);
            ^

[Error: ENOENT: no such file or directory, open 'D:\web\dist\assets\ChangeLog-legacy-d61b07c3.js'] {
  errno: -4058,
  code: 'ENOENT',
  syscall: 'open',
  path: 'D:\\web\\dist\\assets\\ChangeLog-legacy-d61b07c3.js'
}

Node.js v18.16.0
nonzzz commented 1 year ago

Thank for you report. I'll take a look

nonzzz commented 1 year ago

Ok. I found in the example test case that it can work normally if I don’t use legacy plugin. I think i can create a compat logic.

nonzzz commented 1 year ago

Hey. I release the 0.10.3. This version is support it.