简体   繁体   中英

Render React code to HTML file with npm

I didn't know how to name this question but here is the thing. I installed React with NPM: npx create-react-app my-app and I start app with npm start . After that localhost:3000 opens. The thing is html file in folder public isn't connected anyhow to the script.

I want to serve the development with package called "serve". The only thing there is nothing to serve, the HTML file in public isn't updated at all while I can't serve App.js or anything like that.

Is it required to use CDN links for this task? Or how else it is possible to connect React to that generated html file?

You need to setup your environment with Webpack. you can follow this tutorial: https://www.valentinog.com/blog/react-webpack-babel/

Or you can clone a react boilerplate project from github directly.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM