# DEPLOY ANGULAR ##### Yang harus di install ``` - NodeJs - Angular cli - Git - Nginx ``` ##### Clone apps dari gitlab & install ``` git clone git@gitlab.com:sarginsu/belajar-deploy-angular.git atau git clone https://gitlab.com/sarginsu/belajar-deploy-angular.git cd belajar-deploy-angular npm i ``` ##### Build apps ``` ng build --prod atau node --max_old_space_size=8192 ./node_modules/@angular/cli/bin/ng build --prod --aot --build-optimizer --verbose --progress false ``` `*Keterangan: Hasil build ada di folder dist. Hasil build tersebut di copas ke folder nginx untuk di publish.` ##### Copas hasil build ke nginx (Angular Versi 5) ``` rm -rf /var/www/html mv dist /var/www/html ``` ##### Copas hasil build ke nginx (Angular Versi 10++) ``` rm -rf /var/www/html mv dist/belajar-deploy-angular /var/www/html ``` ##### Akses menggunakan browser ``` htpp://ip_server atau htpp://domain_server.com Contoh: http://147.139.192.164/ ``` ### Contoh config nginx untuk angular Lokasi config: `/etc/nginx/sites-available/default` ```json= server { listen 0.0.0.0:80; gzip on; gzip_types text/plain application/xml; gzip_proxied no-cache no-store private expired auth; gzip_min_length 1000; location / { root /var/www/html; try_files $uri $uri/ /index.html; } } ```