nonzzz / vite-plugin-compression

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

构建完成后控制台输出信息报告缺失 #24

Closed Bisstocuz closed 1 year ago

Bisstocuz commented 1 year ago

Bug report 🐞

Version & Environment

  plugins: [
    compression({
      threshold: 1024,
      include: /\.(js|mjs|json|css|html|wasm)$/i,
    }),
    compression({
      algorithm: "brotliCompress",
      threshold: 1024,
      include: /\.(js|mjs|json|css|html|wasm)$/i,
      exclude: /\.(br|gz)$/i,
    })
  ]
{
  "dependencies": {
    "@jsquash/png": "^2.0.0",
    "@jsquash/webp": "^1.1.3",
    "axios": "^1.1.3",
    "pinia": "^2.0.17",
    "vfonts": "^0.0.3",
    "vue": "^3.2.37",
    "vue-router": "^4.1.3"
  },
  "devDependencies": {
    "@rushstack/eslint-patch": "^1.1.4",
    "@vitejs/plugin-vue": "^4.0.0",
    "@vitejs/plugin-vue-jsx": "^3.0.0",
    "@vue/eslint-config-prettier": "^7.0.0",
    "eslint": "^8.23.0",
    "eslint-plugin-vue": "^9.4.0",
    "naive-ui": "^2.33.5",
    "prettier": "^2.7.1",
    "vite": "^4.1.4",
    "vite-plugin-cdn-import-rely": "^3.1.0",
    "vite-plugin-compression2": "^0.8.2",
    "vite-plugin-dynamic-import": "^1.2.3",
    "vite-plugin-remove-console": "^2.1.0",
    "vite-plugin-windicss": "^1.8.8",
    "windicss": "^3.5.6"
  }
}

Expection

image

Actual results (or Errors)

image 只有第一层文件夹的 .gz.br 文件输出到控制台了,但实际上所有文件都正确输出压缩文件到 dist/ 目录下了。

nonzzz commented 1 year ago

只输出了少段信息看起来像是一个未知错误。vite-plugin-compression2 并不负责生成日志。因为所有日志都是交给vite接管的。根据 vite/reporter.ts 这段逻辑我并没有看出什么异常。

Rollup的writeBundle Hook 是发生在generator Hook 后面的。那么在处理非dynamic的文件他应该是可以正常写入到整个context里面的。没有写入到context的只有那些涉及到dynamic的文件。这一点是符合预期的。 @Bisstocuz