In this article we are going to see how to setup our Reactjs Project Environment, with the help of this article you will be able to set up Reactjs Project Based Environment and learn what are the basic packages, files & folders need to be installed and create before you been your actual Project.
npm init |
npm install react react-dom --save |
npm install webpack webpack-dev-server babel-loader babel-core babel-preset-es2015 babel-preset-react babel-preset-stage-2 --save-dev |
var path = require("path"); var DIST_DIR = path.resolve(__dirname, "dist"); var SRC_DIR = path.resolve(__dirname, "src"); var config = { entry: SRC_DIR + "/app/index.js", output: { path: DIST_DIR + "/app", filename: "bundle.js", publicPath: "/app/" }, module: { loaders: [{ test: /\.js?/, include: SRC_DIR, loader: "babel-loader", query: { presets: ["react", "es2015", "stage-2"] }}]}}; module.exports = config; |
console.log("Mitesh Project") |
<!doctype html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0"> <meta http-equiv="X-UA-Compatible" content="ie=edge"> <title>ReactJS Basics </title> <link rel ="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta/css/bootstrap.min.css" integrity="sha384-/Y6pD6FV/Vv2HJnA6t+vslU6fwYXjCFtcEpHbNJ0lyAFsXTsjBbfaDjzALeQsN6M" crossorigin="anonymous"> </head> <body> <div id="app"></div> <script src="/app/bundle.js"></script> </body> </html> |
For Windows users:
"scripts": { "start": "npm run build", "build": "webpack -d && xcopy \"src/index.html\" \"dist/\" /F /Y && webpack-dev-server --content-base src/ --inline --hot", "build:prod": "webpack -p && xcopy \"src/index.html\" \"dist/\" /F /Y" } |
For MAC users:
"scripts": { "start": "npm run build", "build": "webpack -d && cp src/index.html dist/index.html && webpack-dev-server --content-base src/ --inline --hot", "build:prod": "webpack -p && cp src/index.html dist/index.html } |
npm start |
You can see in command line project is running on http://localhost:8082 Open it in your browser and see in your browser console can see console message there.
That’s it, Congratulations You’re setup is up and running.
Are you measuring the correct things? This is where…
Databricks, an advanced solution that uses the Lakehouse architecture…
To stay ahead of the curve, modern companies that…
An invisible agent—sounds too good to be true, doesn’t…
Getting rid of data silos involves more than just…
As we enter a new era of intelligent automation,…