├── .gitignore
├── app.js
├── src
├── appRoot.js
└── mainComponent.js
├── startApp.js
├── webpack.config.js
└── package.json
/.gitignore:
--------------------------------------------------------------------------------
1 | dist
2 |
--------------------------------------------------------------------------------
/app.js:
--------------------------------------------------------------------------------
1 | require = require("esm")(module, { mode: "auto", cjs: true });
2 | require("./startApp");
3 |
--------------------------------------------------------------------------------
/src/appRoot.js:
--------------------------------------------------------------------------------
1 | import React from "react";
2 | import { render } from "react-dom";
3 |
4 | import App from "./mainComponent";
5 |
6 | const target = document.createElement("div");
7 | document.body.appendChild(target);
8 |
9 | render(, target);
10 |
--------------------------------------------------------------------------------
/startApp.js:
--------------------------------------------------------------------------------
1 | import express from "express";
2 | const app = express();
3 | import path from "path";
4 |
5 | app.use("/dist/", express.static(__dirname + "/dist/"));
6 | app.get("/", (req, res) => {
7 | res.sendFile(path.join(__dirname + "/dist/index.html"));
8 | });
9 |
10 | app.listen(3000);
11 |
12 | export default null;
13 |
--------------------------------------------------------------------------------
/src/mainComponent.js:
--------------------------------------------------------------------------------
1 | import React, { useState } from "react";
2 |
3 | export default props => {
4 | const [val, setVal] = useState(0);
5 | return (
6 |
7 |
Hello World!
8 |
9 |
10 | Current Value: {val}
11 |
12 |
13 |
14 |
15 | );
16 | };
17 |
--------------------------------------------------------------------------------
/webpack.config.js:
--------------------------------------------------------------------------------
1 | const path = require("path");
2 | const HtmlWebpackPlugin = require("html-webpack-plugin");
3 |
4 | module.exports = {
5 | entry: {
6 | main: "./src/appRoot.js"
7 | },
8 | output: {
9 | filename: "[name]-bundle.js",
10 | path: path.resolve(__dirname, "dist"),
11 | publicPath: "dist"
12 | },
13 | resolve: {
14 | alias: {},
15 | modules: [path.resolve("./node_modules")]
16 | },
17 | mode: "production",
18 | module: {
19 | rules: [
20 | {
21 | test: /\.js$/,
22 | exclude: /node_modules/,
23 | loader: "babel-loader",
24 | query: {
25 | plugins: ["@babel/plugin-transform-react-jsx"]
26 | }
27 | }
28 | ]
29 | },
30 | optimization: {
31 | minimize: false
32 | },
33 | plugins: [new HtmlWebpackPlugin()].filter(p => p)
34 | };
35 |
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "preact-lightning-talk",
3 | "version": "1.0.0",
4 | "description": "",
5 | "main": "index.js",
6 | "scripts": {
7 | "start": "webpack -w"
8 | },
9 | "repository": {
10 | "type": "git",
11 | "url": "git+https://github.com/arackaf/preact-lightning-talk.git"
12 | },
13 | "author": "",
14 | "license": "ISC",
15 | "bugs": {
16 | "url": "https://github.com/arackaf/preact-lightning-talk/issues"
17 | },
18 | "homepage": "https://github.com/arackaf/preact-lightning-talk#readme",
19 | "dependencies": {
20 | "@babel/core": "^7.6.0",
21 | "@babel/plugin-transform-react-jsx": "^7.3.0",
22 | "babel-loader": "^8.0.6",
23 | "esm": "^3.2.25",
24 | "express": "^4.17.1",
25 | "html-webpack-plugin": "^3.2.0",
26 | "preact": "^10.0.0-rc.1",
27 | "react": "^16.9.0",
28 | "react-dom": "^16.9.0",
29 | "webpack": "^4.40.2",
30 | "webpack-cli": "^3.3.8"
31 | }
32 | }
33 |
--------------------------------------------------------------------------------