Skip to content

Instantly share code, notes, and snippets.

@fusionstrings
Created March 19, 2018 16:27
Show Gist options
  • Save fusionstrings/b8e5a9b3fb7f40b422fc7de8d5386775 to your computer and use it in GitHub Desktop.
Save fusionstrings/b8e5a9b3fb7f40b422fc7de8d5386775 to your computer and use it in GitHub Desktop.
Parcel Express
import React from 'react';
import ReactDOM from 'react-dom';
function Hello(){
return (
<h1>Hello! Parcel App</h1>
);
}
function App(){
return <Hello />
}
ReactDOM.render(<App />, document.getElementById('main'));
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Parcel is awesome</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<main id="main"></main>
<script src="app.js"></script>
</body>
</html>
const Path = require('path');
const Bundler = require('parcel-bundler');
const express = require('express');
const app = express();
const file = Path.join(__dirname, './index.html');
const bundler = new Bundler(file);
app.use(bundler.middleware());
app.use(express.static('dist'));
app.listen(3000, () => {
console.log('server running on port 3000');
});
body {
margin: 0;
padding: 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment