suchen

Heim  >  Fragen und Antworten  >  Hauptteil

node.js - Wie stelle ich ein VueJS-Projekt auf dem Server bereit?

Die von vue-cli erstellte Umgebung, http://localhost:8080/comment..., hat kein Problem damit, darauf zuzugreifen. Jetzt möchte ich vor dem Packen über http://bxu2348550081.my3w.com auf die gleichen Daten zugreifen und Kompilieren. Konfiguration oder Konfiguration auf dem Server?

滿天的星座滿天的星座2802 Tage vor1021

Antworte allen(3)Ich werde antworten

  • 为情所困

    为情所困2017-06-10 09:51:21

    配置一个服务器指向你的dist文件就可以

    我用的nginx

    
    
    server { 
        listen port; 
        server_name your.host.name; 
        rewrite_log             on;
        charset                 utf8;
        root /home/path/xxxxx;
        index index.html;
        
        client_max_body_size    100m;
        
        access_log  /home/xxxx/access.log ;
        error_log  /home/xxxx/error.log;
    
        location ~* \.(html)$ { 
            root /home/path/xxxxx; 
            etag on;
            expires 30d;
            index index.html; 
        } 
    
        gzip on;
        # 启用gzip压缩的最小文件,小于设置值的文件将不会压缩
        gzip_min_length 1k;
        # gzip 压缩级别,1-10,数字越大压缩的越好,也越占用CPU时间,后面会有详细说明
        gzip_comp_level 6;
        # 进行压缩的文件类型。javascript有多种形式。其中的值可以在 mime.types 文件中找到。
        gzip_types text/plain application/javascript application/x-javascript text/css application/xml text/javascript application/x-httpd-php image/jpeg image/gif image/png font/ttf font/otf image/svg+xml;
        # 是否在http header中添加Vary: Accept-Encoding,建议开启
        gzip_vary on;
        # 禁用IE 6 gzip
        gzip_disable "MSIE [1-6]\.";
    
        location ~* \.(css|js|jpg|jpeg|gif|png|ico|cur|gz|svg|svgz|map|mp4|ogg|ogv|webm|htc)$ { 
            root /home/path/xxxxx; 
            index index.html; 
            expires 1M; 
            access_log off; 
            add_header Cache-Control "public"; 
        } 
    
    
    }
    

    Antwort
    0
  • 给我你的怀抱

    给我你的怀抱2017-06-10 09:51:21

    vue build之后吧dist里面的文件,丢上服务器就可以了

    Antwort
    0
  • 天蓬老师

    天蓬老师2017-06-10 09:51:21

    看来你使用的是html5 history模式了,部署的话需要处理一下访问路径的问题,然后把网站文件夹指向dist目录就好了

    参考https://router.vuejs.org/zh-c...

    Antwort
    0
  • StornierenAntwort