发布日期:2021-01-04 16:13:18

参考创建新的 React 应用

cd ~/Documents/company/officalwebsite/

npx create-react-app soosccweb

终端log:

Created git commit.

Success! Created soosccweb at /Users/jason/Documents/company/officalwebsite/soosccweb
Inside that directory, you can run several commands:

  npm start
    Starts the development server.

  npm run build
    Bundles the app into static files for production.

  npm test
    Starts the test runner.

  npm run eject
    Removes this tool and copies build dependencies, configuration files
    and scripts into the app directory. If you do this, you can’t go back!

We suggest that you begin by typing:

  cd soosccweb
  npm start

执行

 cd soosccweb
  npm start
Compiled successfully!

You can now view soosccweb in the browser.

  Local:            http://localhost:3000
  On Your Network:  http://192.168.1.144:3000

Note that the development build is not optimized.
To create a production build, use npm run build.

这时就运行程序了,默认端口3000

运行npm run build 来创建一个build

npm run build

> soosccweb@0.1.0 build /Users/jason/Documents/company/officalwebsite/soosccweb
> react-scripts build

Creating an optimized production build...
Compiled successfully.

File sizes after gzip:

  41.2 KB  build/static/js/2.21832f87.chunk.js
  1.39 KB  build/static/js/3.0c6a8d37.chunk.js
  1.16 KB  build/static/js/runtime-main.e02712dc.js
  590 B    build/static/js/main.d46a0c86.chunk.js
  531 B    build/static/css/main.8c8b27cf.chunk.css

The project was built assuming it is hosted at /.
You can control this with the homepage field in your package.json.

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:

  https://cra.link/deployment

 

如果希望安装material-ui, 则可以运行

npm install @material-ui/core

发表评论