如何打包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