Skip to content

A tiny getting started for a react project, with front-end built with parcel, and served through express.

License

Notifications You must be signed in to change notification settings

ccamel/tutorial-react-parcel-express

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Tutorial - express / parcel / react

A tiny getting started for a react project, with front-end built with parcel, and served through express.

Setup project

  • npm init -y
  • npm install parcel-bundler nodemon concurrently --save-dev
  • npm install react react-dom express --save
  • Add to scripts in package.json:
    "build-watch": "parcel watch ./client/index.html",
    "start-watch": "nodemon server/index.js",
    "dev": "concurrently --kill-others \"npm run start-watch\" \"npm run build-watch\"",
    "build": "parcel build ./client/index.html",
    "start": "npm run build && node server/index.js",

Html

Put in client/index.html

<!DOCTYPE html>
<html lang="en">
  <head>
    <title>Hi</title>
  </head>
  <body>
    <div id="root"></div>
    <script src="./index.js"></script>
  </body>
</html>

Client Javascript

Put in client/index.js

import React from 'react';
import ReactDOM from 'react-dom';

ReactDOM.render(
  <h1>Hello World!</h1>,
  document.getElementById('root')
);

Server Javascript

Put in server/index.js

const express = require('express')
const app = express()

app.use(express.static('dist'))

app.listen(3000, () => console.log('Listening on port 3000!'))

Development with auto reloading

Run

About

A tiny getting started for a react project, with front-end built with parcel, and served through express.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 64.0%
  • HTML 36.0%