I'm a newbie with React, I have made a few apps using the create-react-app to help get me started(as followed by numerous tutorials). I heard that I now need to know how to create a react app from scratch without using the create-react-app boilerplate maker.
I know that i have to add a few sections such as:
here are the list of dependencies in my package.json file
"dependencies": {
"prop-types": "^15.6.1",
"react": "^16.4.0",
"react-dom": "^16.4.0"
},
"devDependencies": {
"babel": "^6.23.0",
"babel-loader": "^7.1.4",
"babel-preset-env": "^1.7.0",
"babel-preset-react": "^6.24.1",
"babel-preset-stage-0": "^6.24.1",
"html-webpack-plugin": "^3.2.0",
"webpack": "^3.8.3",
"webpack-dev-server": "^3.1.4"
}
}
webpack.config.js
var path = require('path');
var webpack = require('webpack');
var HtmlWebpackPlugin = require('html-webpack-plugin');
module.exports = {
devtool: 'cheap-module-eval-source-map',
entry: {
app:'./src/index',
},
output: {
path: path.join(__dirname, 'dist'),
filename: 'bundle.js',
publicPath: '/static/'
},
plugins: [
new HtmlWebpackPlugin(['app'])
],
module: {
loaders: [{
test:/\.js/ + /\.jsx?$/,
loader: 'babel-loader',
include: path.join(__dirname, 'src'),
}]
}
}
My .babelrc file
{
"presents":["env","react"]
}
I've followed a few tutorials on how to make a React app from scratch, but with no success. I have a feeling that my Webpack config is not correct.
Unfortunately I am still unable to run this project
Git link to repo: https://github.com/tony2tones/scratch-react/tree/master
As mentioned earlier, you need an
index.js
and inside of it you will need to at least have: import React from 'react';
import ReactDOM from 'react-dom';
and
`ReactDOM.render(whatever you want to render, wherever you want to render(preferably document.getElementById('root')))
This shows what the app should render when it gets a request
Hope this will help. it's my first answer :)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With