我想在 ViteJS 和 React 中压缩我的文件。我使用了 vite-plugin-compression 并导入了它:
import viteCompression from 'vite-plugin-compression';
plugins: [viteCompression({ algorithm: 'brotliCompress'}),
当我使用时:
npm run build
我将我的文件作为 index-123.js index-123.css 和 index-123.js.br index-123.css.br 在资产和我的 index.html 中。它使用 .js 文件,即使我手动将它更改为 .js.br 和 .css.br 它也不会工作
这是index.html:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="./assets/logo-d3a0dcae.svg" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Name of Project</title>
<script type="module" crossorigin src="./assets/index-4402516d.js"></script>
<link rel="stylesheet" href="./assets/index-85e30739.css">
</head>
<body>
<div id="root"></div>
</body>
</html>