React production environment using CDN
- Change .../react.development.js to .../react.production.min.js
- Change .../react-dom.development.js to .../react-dom.production.min.js
- Install babel-cli and babel-preset-react-app@3
npm i babel-cli babel-preset-react-app@3
- Put index.js to /src folder
- Delete
<script src="https://unpkg.com/@babel/standalone/babel.min.js"></script>
from index.html - Attach script to index.html from /dist folder
<script src="./dist/index.js"></script>
- Run
npx babel --watch src --out-dir dist --presets react-app/prod
for watch mode
"scripts": {
"build:prod": "npx babel src --out-dir dist --presets react-app/prod",
"watch:prod": "npx babel --watch src --out-dir dist --presets react-app/prod"
},
Done