An open API service indexing awesome lists of open source software.

https://github.com/kwhitley/parcel-playground


https://github.com/kwhitley/parcel-playground

Last synced: 3 months ago
JSON representation

Awesome Lists containing this project

README

        

# 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:

```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`

```html


Hi




```

## Client Javascript

Put in `client/index.js`

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

ReactDOM.render(

Hello World!

,
document.getElementById('root')
);
```

## Server Javascript

Put in `server/index.js`

```javascript
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

* `npm run dev`
* Visit http://localhost:3000
* Change some files!

## Run

* `npm start`
* Visit http://localhost:3000