新建React+ts+sass项目

581 阅读1分钟

添加脚手架 create-react-app

yarn global add create-react-app

使用 create-react-app 创建react项目,指定ts

create-react-app react-demo --template typescript

使用 sass

yarn add node-sass -D

添加好后直接将.css文件替换成.scss文件即可

运行指定端口

  • 法一:PORT=8888 yarn start
  • 法二:修改package.json 中 start 命令
  "scripts": {
    "start": "PORT=8888 react-scripts start", // ===> 这里指定端口
    "build": "react-scripts build",
    "test": "react-scripts test",
    "eject": "react-scripts eject"
  },