I’ trying to build an extremely simple app to show the message ‘success’ in the browser.
After I do npm run build
it compiles to ../dist/index.js
.
Im using live reload on vsCode to run index.html
in the browser and I’m still failing. What am I missing or doing wrong?
I’m trying to only use babel instead of webpack or react-scripts
./publc/index.html
<html>
<body>
<div id="root"></div>
<script src="../dist/index.js"></script>
</body>
</html>
./src/index.js
import ReactDOM from 'react-dom';
import React, { Component } from 'react';
class App extends Component {
render() {
return (
<div>success</div>
);
}
}
ReactDOM.render(<App/>, document.querySelector('#root'))
.babelrc
{"presets": [
"env", "react"
]}
package.json
{
"name": "doms-app",
"scripts": {
"build": "babel src -d dist -w"
},
"devDependencies": {
"babel-preset-react": "^6.24.1",
"babel-cli": "^6.26.0",
"babel-core": "^6.26.3",
"babel-preset-env": "^1.7.0"
},
"license": "ISC",
"dependencies": {
"react": "^16.5.2",
"react-dom": "^16.5.2"
}
}