snowpack 事始め
おもろそうだったので様子見
元々 @pika/web
だったのが snowpack
になったっぽい
シンプルに
npm の module を
web_modules
以下にバンドルしてくれて
esm でロードできるようにしてくれるやつ、って感じか?
shelly add preact
y add -D snowpack
snowpack
y add -D serve
serve
open http://localhost:5000
index.html<div id="app"></div>
<script type="module" src="/src/app.js"></script>
src/app.jsimport { h, Component, render } from '/web_modules/preact.js'
const app = h('div', null, 'Helloooo')
render(app, document.getElementById('app'))
動く
src/app.jsimport { h, Component, render } from '/web_modules/preact.js'
import htm from '/web_modules/htm.js'
const html = htm.bind(h)
const app = html`
<div>yo yo</div>
`
render(app, document.getElementById('app'))
動く
src/app.jsimport { h, Component, render } from '/web_modules/preact.js'
import htm from '/web_modules/htm.js'
import css from '/web_modules/csz.js'
const html = htm.bind(h)
const style = css`
color: #f00;
`
const app = html`
<div class="${style}">yo yo</div>
`
render(app, document.getElementById('app'))
動く