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

目的:

  1. 但願找到像Vue-cli相似的腳手架,便於入門。
  2. 經過此項目學習React。

參考地址:

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

系統:

macOSgit

過程:

  • 將npm升級到5.2以上,將有一個新的包,npx。npx 會自動查找當前依賴包中的可執行文件,若是找不到,就會去
    PATH裏找。若是依然找不到,就會幫你安裝。

    npx create-react-app my-appgithub

clipboard.png

cd 目錄地點



npm start

運行開發環境npm

npm test

測試json

npm run build

運行發佈環境。
我此次暫且選在Github Pages充當發佈環境。app

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中看到發佈後的項目。ui

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

相關文章
相關標籤/搜索