Skip to content
This repository has been archived by the owner on Jan 3, 2023. It is now read-only.

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

witchard/tutorial-react-parcel-express

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Tutorial - express / parcel / react

ARCHIVED AS NO LONGER MAINTAINING

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