ganatan / angular-app

Angular 18 ,Bootstrap 5, Node.js, Express.js, CRUD, PWA, SSR, SEO, Lazy Loading, Examples Angular & React nrwl
647 stars 315 forks source link

Your live demo file size is so small #4

Closed thinhnd580 closed 4 years ago

thinhnd580 commented 4 years ago

Your demo file size is so small. I build with ssr and check with your live demo. It seem like you used some compressions or something to compress that make main style.css file from 221kb to 38kb. Can you tell me how do you do that. Thank you very much

ganatan commented 4 years ago

Hi thinhnd580,

I give you all the stuff

The nginx.conf below

Don't forget, if you like you star.

worker_processes auto;

events {
    worker_connections 768;
}

http {

    gzip on;
    gzip_http_version 1.1;
    gzip_comp_level 5;
    gzip_min_length 256;
    gzip_proxied any;
    gzip_vary on;
    gzip_types
    application/atom+xml
    application/javascript
    application/json
    application/rss+xml
    application/vnd.ms-fontobject
    application/x-font-ttf
    application/x-web-app-manifest+json
    application/xhtml+xml
    application/xml
    font/opentype
    image/svg+xml
    image/x-icon
    text/css
    text/plain
    text/x-component;

    sendfile on;

    server {
        if ($host = your_domain.com) {
            return 301 https://$host$request_uri;
            } 

            listen 80;
            server_name your_domain.com;
            return 301 https://www.your_domain.com$request_uri;

        }

        server {
            if ($host = www.your_domain.com) {
                return 301 https://$host$request_uri;
                } 

                listen 80;
                server_name www.your_domain.com;
                return 301 https://www.your_domain.com$request_uri;

            }

            server {
                if ($host = angular.your_domain.com) {
                    return 301 https://$host$request_uri;
                    } 

                    listen 80;
                    server_name angular.your_domain.com;
                    return 301 https://angular.your_domain.com$request_uri;

                }

                server {
                    listen 443 ssl http2;
                    listen [::]:443 ssl http2;
                    server_name www.your_domain.com;
                    ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
                    ssl_ciphers HIGH:!aNULL:!MD5;
                    ssl_certificate /etc/letsencrypt/live/www.your_domain.com/fullchain.pem;
                    ssl_certificate_key /etc/letsencrypt/live/www.your_domain.com/privkey.pem;

                    location / {
                        proxy_pass http://127.0.0.1:4000;
                    }

                }

                server {
                    listen 443 ssl http2;
                    listen [::]:443 ssl http2;
                    server_name your_domain.com;
                    ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
                    ssl_ciphers HIGH:!aNULL:!MD5;
                    ssl_certificate /etc/letsencrypt/live/your_domain.com-0001/fullchain.pem;
                    ssl_certificate_key /etc/letsencrypt/live/your_domain.com-0001/privkey.pem;

                    location / {
                        proxy_pass http://127.0.0.1:4000;
                    }

                }

                server {
                    listen 443 ssl http2;
                    listen [::]:443 ssl http2;
                    server_name angular.your_domain.com;
                    ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
                    ssl_ciphers HIGH:!aNULL:!MD5;
                    ssl_certificate /etc/letsencrypt/live/angular.your_domain.com-0002/fullchain.pem; 
                    ssl_certificate_key /etc/letsencrypt/live/angular.your_domain.com-0002/privkey.pem;

                    location / {
                        proxy_pass http://127.0.0.1:4001;
                    }

                }

            }