preactjs / preact-cli

😺 Your next Preact PWA starts in 30 seconds.
MIT License
4.69k stars 375 forks source link

Request for supersimple template #478

Closed bestwestern closed 6 years ago

bestwestern commented 6 years ago

Is it possible to get a supersimple template with the absolute basic (no service worker, icons etc)

I tried the simple, build it and deployed it to https://build-hdqxfhiann.now.sh/ 77kb transferred: image

developit commented 6 years ago

Service Worker is something preact-cli does unrelated to the template. You can turn it off via the --no-serviceworker flag.

You might find it worthwhile to skip using preact create if you're looking for something really simple:

mkdir demo && cd $_       // create folder
git init && npm init -y   // initialize git & npm
npm i -D preact-cli       // install the CLI
// here's the minimal app:
echo "export default () => <h1>Hello, World</h1>" > index.js
// start the dev server:
$(npm bin)/preact watch
bestwestern commented 6 years ago

Thank you very much. That was dumb of me not to try that from the readme file :-/

i tried setting the --no-serviceworker flag and it got much better, but how come it uses 4.5 kb? (preact is about 3kb)

image

lukeed commented 6 years ago

There's preact-router in there & some extra logic to handle async/fetching routes once your app starts growing.

bestwestern commented 6 years ago

I see! I didn't think it would be included when it wasn't imported.

In that case - is it possible to avoid including the router?

developit commented 6 years ago

Hmm - when I follow the steps, I get a 3.8kb app. That makes sense, you have 3.3kb of Preact and then around 500b of app code + webpack (for things like setting up module boundaries and split point loading).

bestwestern commented 6 years ago

Very strange. I am sorry, I am having trouble with those flags. Could you please write your last step:

bestwestern commented 6 years ago

Argh - what tricked me is that when building with no service-worker the sw file is still created, it is just not used. These worked:

But my build folder looks like this image

Is that the same as yours @developit ? (If so, the 3.8 kb you're getting is a deployment/gzipping thing?) @lukeed I don't think the router is included? (remember this is the simple template)

PS: Thank you very much for taking the time for answering questions. I would like to add a few lines of example commands to the readme file, to (literally) foolproof it, so other dumbasses like me don't take up your time (You must be busy now at Google (congrats on that) ;-)

ForsakenHarmony commented 6 years ago

Yes, the 3.8kb are gzipped

bestwestern commented 6 years ago

@ForsakenHarmony thank you - how do you see the size before deploying it?

developit commented 6 years ago

Sorry for missing this thread @bestwestern! I definitely see the need for some readme explanations here, and we can probably address some of the confusing bits with tweaked defaults.

For anyone finding this - A nice quick way to see the gzipped size of a file on disk is gzip-size-cli:

npm i -g gzip-size-cli

gzip-size dist/bundle.2b3ef.js
bestwestern commented 6 years ago

Awesome - thanks @developit .