Ant design pro部署到nginx

打包

在ant design pro工程目录下,使用一条命令就可以打包:

cnpm run build

返回结果

> ant-design-pro@1.0.0 build D:\antd_prj
> umi build

Build completed in 58.478s

 DONE  Compiled successfully in 58489ms                                                                         14:00:21

File sizes after gzip:

  609.8 KB   dist\umi.4d500ed4.js
  142.17 KB  dist\layouts__BasicLayout.0092a8ac.async.js
  125.08 KB  dist\vendors.c594db8f.async.js
  31.77 KB   dist\umi.b34a2b0a.css
  14.42 KB   dist\layouts__BasicLayout.983e7e45.chunk.css
  4.61 KB    dist\vendors.faf32610.chunk.css
  3.01 KB    dist\p__user__login.9575e440.async.js
  1.22 KB    dist\layouts__UserLayout.3245de9b.async.js
  981 B      dist\p__user__login__model.ts.e5534ac8.async.js
  697 B      dist\p__account__settings__model.ts.e474e4dd.async.js
  643 B      dist\layouts__UserLayout.b382bf5b.chunk.css
  417 B      dist\p__user__login.ce2f87ca.chunk.css
  234 B      dist\layouts__BlankLayout.fa3ae8ad.async.js

将打包好的文件在dist目录下,将dist所有文件拷贝到nginx根目录下。

v2-f99f2cf574ad8159d8b6e06a7b8ee18b_b.jpg

配置nginx

server {
        listen       8188;
        server_name  localhost;

		# gzip config
		gzip on;
		gzip_min_length 1k;
		gzip_comp_level 9;
		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;
		gzip_vary on;
		gzip_disable "MSIE [1-6]\.";

        #charset koi8-r;

        #access_log  logs/host.access.log  main;

        location / {
            root   html;
            index  index.html index.htm;
			try_files $uri $uri/ /index.html;
        }

        #error_page  404              /404.html;

        # redirect server error pages to the static page /50x.html
        #
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }

        location ^~ /api {
            proxy_pass http://192.168.1.105:8080;
            proxy_set_header   X-Forwarded-Proto $scheme;
            proxy_set_header   X-Real-IP         $remote_addr;
        }
    }

最主要的是配置location,所有向服务器的以api开头的访问,都被代理到192.168.1.105:8080,注意8080后面没有加“/”。

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值