- 新增 .env.development 文件,配置开发环境变量 - 新增 .env.production 文件,配置生产环境变量及压缩选项 - 添加 .gitignore 文件,忽略常见临时文件和本地配置 - 新增 .npmrc 文件,配置私有npm仓库及认证信息 - 新增 .prettierrc.json,配置代码格式化规则 - 添加 403 错误页面背景图 svg 文件至 public/img/bg/目录
28 lines
641 B
JavaScript
28 lines
641 B
JavaScript
import compression from 'vite-plugin-compression';
|
|
|
|
export default function createCompression(env) {
|
|
const { VITE_BUILD_COMPRESS } = env;
|
|
const plugin = [];
|
|
if (VITE_BUILD_COMPRESS) {
|
|
const compressList = VITE_BUILD_COMPRESS.split(',');
|
|
if (compressList.includes('gzip')) {
|
|
plugin.push(
|
|
compression({
|
|
ext: '.gz',
|
|
deleteOriginFile: false,
|
|
})
|
|
);
|
|
}
|
|
if (compressList.includes('brotli')) {
|
|
plugin.push(
|
|
compression({
|
|
ext: '.br',
|
|
algorithm: 'brotliCompress',
|
|
deleteOriginFile: false,
|
|
})
|
|
);
|
|
}
|
|
}
|
|
return plugin;
|
|
}
|