菜单 学习猿地 - LMONKEY

VIP

开通学习猿地VIP

尊享10项VIP特权 持续新增

知识通关挑战

打卡带练!告别无效练习

接私单赚外块

VIP优先接,累计金额超百万

学习猿地私房课免费学

大厂实战课仅对VIP开放

你的一对一导师

每月可免费咨询大牛30次

领取更多软件工程师实用特权

入驻
30
0

如何打包react生成的项目

原创
05/13 14:22
阅读数 959

如何打包react生成的项目

1、点击开始-菜单-运行-cmd

2、使用cd命令切换到react项目根目录

3、执行npm run build命令进行打包

打包完成后会在项目目录下生成一个build文件夹,build生成的这些东西要放在服务器root下

下面是一个完整的打包过程:

D:\node.js\xxx\app>npm run build

> app@0.1.0 build D:\node.js\xxx\app
> node scripts/build.js

Creating an optimized production build...
Compiled successfully.

File sizes after gzip:

  39.92 KB  build\static\js\2.3eed503d.chunk.js
  767 B     build\static\js\runtime-main.3127cda7.js
  606 B     build\static\js\main.1649de4d.chunk.js
  547 B     build\static\css\main.d1b05096.chunk.css

The project was built assuming it is hosted at the server root.
You can control this with the homepage field in your package.json.
For example, add this to build it for GitHub Pages:

  "homepage" : "http://myname.github.io/myapp",

The build folder is ready to be deployed.
You may serve it with a static server:

  npm install -g serve
  serve -s build

Find out more about deployment here:

  bit.ly/CRA-deploy


D:\node.js\xxx\app>

发表评论

0/200
30 点赞
0 评论
收藏
为你推荐 换一批