node v18
npm start- React, Typescript
Create React App has its own templating - in webpack.config.js (react-scripts/config), see HtmlWebpackPlugin which will fill in PUBLIC_URL should you have one.
The problem is, that if custom variables wanted to be introduced, it will complain that these variables are not defined.
How to solve?
- npm run eject
- and then manually add these variables into the template to result into the format that your own template will understand
templateParameters: {
'nameOfParam': '<YOUR TEMPLATE SYNTAX>'
}
- hack around with env variables
- the hierarchy is that the templating engine will look for env variables in
.envfile to populate the html. For local development then use.env.local - careful, env variables need to have
REACT_APPprefix!