脚本宝典收集整理的这篇文章主要介绍了官方create-react-app 入门(一),脚本宝典觉得挺不错的,现在分享给大家,也给大家做个参考。
目的:
参考地址:
https://github.com/facebook/c...
系统:
macOS
过程:
- 将npm升级到5.2以上,将有一个新的包,npx。npx 会自动查找当前依赖包中的可执行文件,如果找不到,就会去
PATH里找。如果依然找不到,就会帮你安装。npx create-react-app my-app
cd 目录地点
npm start
运行开发环境
npm test
测试
npm run build
运行发布环境。
我这次暂且选在GIThub Pages充当发布环境。
GitHub Pages
- 在Package.json中添加homepage
"homepage": "https://myusername.github.io/my-app"
,
或者 "homepage": "https://myusername.github.io",
- Install gh-pages and add deploy to scripts in package.json
npm install --save gh-pages
"scripts": { "predeploy": "npm run build", "deploy": "gh-pages -b master -d build", }
- Deploy the site by running npm run deploy
npm run deploy
- Ensure your PRoject’s settings use gh-pages
结果就可以在Gighubpage中看到发布后的项目。
第一次写博客文章,希望能坚持下去养成习惯,让自己变成自己希望的人。
以上是脚本宝典为你收集整理的官方create-react-app 入门(一)全部内容,希望文章能够帮你解决官方create-react-app 入门(一)所遇到的问题。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。