Created
May 12, 2020 19:07
-
-
Save developit/2cdcb1e8e979cf41354f2fa17220488b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>Preact App with Microbundle</title> | |
<link rel="stylesheet" href="/style.css"> | |
</head> | |
<body> | |
<div id="preact_root"></div> | |
<script type="module" src="bundle.js"></script> | |
</body> | |
</html> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { h, render } from 'preact'; | |
import { useReducer } from 'preact/hooks'; | |
function App() { | |
const [count, increment] = useReducer(c => c + 1, 0); | |
return ( | |
<div> | |
{count} | |
<button onClick={increment}>Increment</button> | |
</div> | |
); | |
} | |
render(<App />, window.preact_root); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"name": "microbundle-preact-example", | |
"version": "1.0.0", | |
"source": "index.js", | |
"scripts": { | |
"build": "microbundle index.js -f modern -o bundle.js", | |
"dev": "npm run -s serve & npm run -s build -- --watch", | |
"serve": "sirv -Dq" | |
}, | |
"dependencies": { | |
"preact": "^10.4.1" | |
}, | |
"devDependencies": { | |
"microbundle": "^12.0.0", | |
"sirv-cli": "^0.4.5" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment