如何解决在Firebase托管上通过gulp文件提供gzip压缩服务
我有Angular 9应用程序,该应用程序还不够大,但是main.js包的大小为1.7Mb。 package.json中只有很少的依赖项
"dependencies": {
"@angular/animations": "~9.0.2","@angular/cdk": "^9.0.1","@angular/common": "~9.0.2","@angular/compiler": "~9.0.2","@angular/core": "~9.0.2","@angular/fire": "^6.0.2","@angular/forms": "~9.0.2","@angular/material": "^9.0.1","@angular/platform-browser": "~9.0.2","@angular/platform-browser-dynamic": "~9.0.2","@angular/router": "~9.0.2","firebase": "^7.9.3","ngx-image-cropper": "^3.1.9","rxjs": "~6.5.4","tslib": "^1.10.0","zone.js": "~0.10.2"
在ng-build --prod
函数之后,我启动gulp compress
以gzip所有构建的文件:
let gulp = require('gulp');
let gzip = require('gulp-gzip');
gulp.task('compress',function() {
return gulp.src(['./dist/**/*.*'])
.pipe(gzip())
.pipe(gulp.dest('./dist'));
});
Here I have this list of files in dist directory:
尝试了不同的方式(包括仅提供.gz文件),但是我收到了一个错误消息,也没有得到同样大小的文件。任何帮助都将非常有用,谢谢!
解决方法
Firebase托管会自动使用gzip压缩,因此您不应该手动进行压缩。
您上传的每个文件都缓存在世界各地CDN边缘的SSD上,并用作gzip或Brotli。我们会为您的内容自动选择最佳的压缩方法。无论您的用户在哪里,内容都能快速交付。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。