block by shawnbot 53600929cc8735e8e4fe26a960c0d4cb

Parcel + Preact

Full Screen

index.js

import React from 'react'
import {render} from 'react-dom'
import styled from 'styled-components'

const Box = styled.div`
  background-color: #eee;
  border: 1px solid #999;
  padding: 1em;

  > * {
    margin: 0;
  }
`

render((
  <Box>
    <h1>Hello, world!</h1>
  </Box>
), document.getElementById('app'))

index.html

<!doctype html>
<html lang="en">
  <head>
    <title>Parcel + React test</title>
  </head>

  <body>
    <div id="app"></div>
    <script src="./index.js"></script>
  </body>
</html>

package.json

{
  "private": true,
  "main": "index.js",
  "scripts": {
    "start": "parcel index.html",
    "prebuild": "rm -rf dist",
    "build": "NODE_ENV=production parcel build",
    "postbuild": "gzip-size dist/*.js"
  },
  "keywords": [],
  "author": "",
  "license": "ISC",
  "devDependencies": {
    "babel-preset-env": "^1.6.1",
    "babel-preset-react": "^6.24.1",
    "gzip-size-cli": "^2.1.0",
    "parcel-bundler": "^1.7.1"
  },
  "dependencies": {
    "react": "^16.3.2",
    "react-dom": "^16.3.2",
    "styled-components": "^3.2.5"
  }
}