I have an angular app I am serving locally with browser sync through a gulp file.
var argv = require('yargs').argv;
var browserSync = require('browser-sync').create();
var gulp = require('gulp');
var gzip = require('gulp-gzip');
var compression = require("compression");
//use compression to set response gzip headers
gulp.task('serve', function () {
browserSync.init({
server: {
baseDir: paths.public,
middleware: compression()
},
port: port
});
});
//gzip js and add to public
gulp.task('js', function () {
return (source('app.js'))
.pipe(gzip({append: false}))
.pipe(gulp.dest(paths.public))
});
index.html
<script src="app.js"></script>
request headers: Accept-Encoding:gzip, deflate, sdch, br
response header: Content-Encoding:gzip
gzipped app.js that get's returned to browser
�ܽk{�F�0�y�+ �^ �Z��dvwH�\ŗD;��23{(ƃIH$@�e����SU}A7.����yޣɘ@�/��U�U����x�E�4Ϭ�Y���Z��N�V�:;{�0��%=}
+��w�$[Er�J���mY�>8�},�:8�"Y���
�ҽS�S���4�u�gɭ��(�±�Y�/�q���<�W��:���#��v��i��Zc/��ķ_�y��ՋO?����囏??��x���|��_'_y�,{����}���(�͜�'>1 ���f>e<
�Q_�Z:� �%���XU2aw[��� ��A�C�1w����'�7K��r�Ϗ���)�
�����zC���q,1Ѷ������X����NN��$\���y�,�E��J��~�&�QM�+�++���$~���|k��ӬC�gI ���>}�|�?}�^��^+V�l�D�V:���%�Ӏ�Hh5(��֑����$���rL�
X�$X&V`!�
Basically it looks like I am successfully gzipping the file and serving it and it looks like the browser recieves the gzipped file and has the headers to know that it should unzip it but it lands at the browser as this bizarrely encoded text.
When I look at the code on the server locally it is just binary.
Any idea what I need to be doing here to get the browser to ungzip and load my script?