0

I want to optimize Angular APP with .Net Core I use this Command in cmd -> ng build --prod and it works fine to minify all Jscript files in \dist Folder

but i want to use gzip to compress those Jscript Files

I installed GZip-all
https://www.npmjs.com/package/gzip-all
I use this Command
->ng build --prod && gzip-all \"dist/anti-fraud/.\"
and tried another one
    ng build --prod && gzip-all \"dist/*.*\"

but it gives this message "'gzip-all' is not recognized as an internal or external command, operable program or batch file."

and this happens with any package i install like tar
->ng build --environment=prod && tar -zcvf archive.tar.gz dist/prod/*
also with Zipper
->ng build --prod && gzipper --verbose ./dist
gives Message"'gzipper' is not recognized as an internal or external command, operable program or batch file."

and Not compress any file in dist folder
any help?

Edit:
I have find the solution
I have not installed gzip in the global so i installed it
->npm -g i gzip-all
then

  ng build --prod && gzip-all dist/*.* 


it works good :)

Sara
  • 23
  • 6

1 Answers1

0

You have to differentiate minification and gzip compression.

Minifying/uglyfying your JS is normally done automatically with the following command

ng build --prod

unless you turned off that setting in angular.json file.

Then, you can ask your web server to dynamically compress these files with gzip (or other compression method) so that it takes less time to transfer over the network.

Getting this done depends on your webserver (example for for IIS, for nginx)

David
  • 28,746
  • 10
  • 68
  • 95
  • after installing it in global gives this message gzipped 0 files – Sara Jul 24 '19 at 14:37
  • thank you :) I have not installed gzip in the global so i installed it ->npm -g i gzip-all then ng build --prod && gzip-all dist/*.* it works good :) – Sara Jul 24 '19 at 15:13
  • Gettiing an error- The token '&&' is not a valid statement separator in this version. + CategoryInfo : ParserError: (:) [], ParentContainsErrorRecordException + FullyQualifiedErrorId : InvalidEndOfLine – HamidKhan Apr 18 '20 at 03:56