I am using gulp to uglify, concat and compress my javasscripts. When i run all.js script on my website its give me below highlighted error. But if i don't compress and only concat and ugilfy everything works fine than. I don't know why its is giving me this error by compressing. For compressing i am using jstuckey/gulp-gzip module.
Browser console:
Uncaught SyntaxError: Invalid or unexpected token
gulpfile.js:
gulp.task('all_scripts', function () { return gulp.src(['app/app.js', 'app/services/*.js', 'app/directives/*.js', 'app/components/**/*.js', 'app/routing_components/**/*.js']) .pipe(concat('all.js')) .pipe(uglify()) .pipe(gzip()) //by commenting this all.js works fine .pipe(gulp.dest('app')); }); Note: In my directory app/all.js.gz occur after running gulp all_scripts. But in browser its giving me error.
In browser for all.js, i am getting network response with "Accept-Encoding:gzip, deflate, br" and status 200:
P�{P�e��*�y?R�%'S����+D0�՞����v_�l��/H� ���|�! ��MrX��� O�Vg��d�K�<����}ݑ�QP��y#(R�6�e� �C�q����+1S��Y�D�鳑����G�)_"@3Y&��I�P�w@}�O�w�h[���;���!pWʂl�[�8T���R��WqI^�E�O�u�6�����������Q̩��bS��s @b�d�8>�یl�/ƛm� �02�믔�c3:η�̧eM�����zU�Q����,ζ�1��֣b�P��,�mR�\@����+G��Q� �U�9J��`]+�˺�TK����,=��f�(�O����y��C�N/�l�STS݁�P-�I���9�"#�� $�G�^͡�P=�j� ~/�!V㖣'�b�X���j ��,^F��{��6�u�y6ۢL2��b�*y�)�� ��r��C��I?�f�2re��,T�b� T��(� ��$`[Z�u�Z�$�H| �t��S7C ���R]Z�(|p����S4�#]AZW�
var gzip = require('gulp-gzip');in your gulp script?