官方create-react-app 入門(一)

目標:

  1. 願望找到像Vue-cli相似的腳手架,便於入門。
  2. 經由歷程此項目進修React。

參考所在:

https://github.com/facebook/c…

體系:

macOS

歷程:

  • 將npm升級到5.2以上,將有一個新的包,npx。npx 會自動查找當前依靠包中的可執行文件,假如找不到,就會去
    PATH里找。假如依舊找不到,就會幫你裝置。

    npx create-react-app my-app

《官方create-react-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中看到宣布后的項目。

第一次寫博客文章,願望能堅持下去養成習氣,讓本身變成本身願望的人。

    原文作者:shutingwen
    原文地址: https://segmentfault.com/a/1190000015050448
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞