add preact with webpack

This commit is contained in:
Thomas Ruoff
2017-02-15 00:46:54 +01:00
parent 316d05790b
commit 7668fc3837
15 changed files with 229 additions and 3 deletions

13
webapp/index.html Normal file
View File

@@ -0,0 +1,13 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>PDFer</title>
<meta name="application-name" content="PDFer">
</head>
<body>
<div id="root">
<div id="app">Loading</div>
</div>
</body>
</html>

19
webapp/index.js Normal file
View File

@@ -0,0 +1,19 @@
import { render } from 'preact';
function init() {
const App = require('./views').default;
render(App, document.getElementById('root'), document.getElementById('app'));
}
init();
if (process.env.NODE_ENV === 'production') {
console.log('for real now');
} else {
// use preact's devtools
require('preact/devtools');
// listen for HMR
if (module.hot) {
module.hot.accept('./views', init);
}
}

BIN
webapp/static/favicon.ico Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

0
webapp/styles/styles.css Normal file
View File

View File

@@ -0,0 +1,10 @@
import { h } from 'preact';
import { Link } from 'preact-router';
export default function () {
return (
<header className="header">
<h1>PDFer</h1>
</header>
)
}

View File

@@ -0,0 +1,13 @@
import { h } from 'preact';
import Header from './Header';
export default function (props) {
return (
<div id="app">
<Header />
<div id="content">
{ props.children }
</div>
</div>
);
}

15
webapp/views/index.js Normal file
View File

@@ -0,0 +1,15 @@
import { h } from 'preact'
import { Router } from 'preact-router';
import Home from './pages/Home';
import Layout from './components/Layout';
import Error404 from './pages/404';
export default (
<Layout>
<Router>
<Home path="/" />
<Error404 default />
</Router>
</Layout>
);

10
webapp/views/pages/404.js Normal file
View File

@@ -0,0 +1,10 @@
import { h } from 'preact';
export default function (props) {
return (
<div>
<h2>No hope!</h2>
<p>Not sure what you desire, but look for somewhere else...</p>
</div>
);
}

View File

@@ -0,0 +1,11 @@
import { h } from 'preact';
export default function (props) {
return (
<div>
<h1>Home</h1>
<p>This is the home page.</p>
<p>Anything is insane</p>
</div>
);
}