Here Webpack is used to build react jsx.
webpack.config.js
- entryPoint: points to React index.js that resides in client/index.js
- outputDir : /static/bundle.js( after the build is complete the bundle.js go in this folder
app.js
app.use("/api/v1/users", userRouter)
- all the /api/v1/users request goes to userRouter
app.use("/*", indexRouter)
- all the / request goes to index.js router which in return route it to index.ejs
- in index.ejs react js bundle file is included , hence routing for /* will be handled by react routers
- in index.ejs the react component will be rendered inside
<div id="root"></div>
similar to create-react-app we have public/index.html there , here we have index.ejs
Here Webpack is used to build react jsx.
webpack.config.js
app.js
app.use("/api/v1/users", userRouter)app.use("/*", indexRouter)<div id="root"></div>