Preact-cli: Request for supersimple template

Created on 2 Feb 2018  路  11Comments  路  Source: preactjs/preact-cli

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

Most helpful comment

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

All 11 comments

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

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

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

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?

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).

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

  • preact create simple app
  • cd app
  • ?

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:

  • npm run build -- --service-worker false
  • preact build --service-worker false

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) ;-)

Yes, the 3.8kb are gzipped

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

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

Awesome - thanks @developit .

Was this page helpful?
0 / 5 - 0 ratings

Related issues

jpoo90 picture jpoo90  路  4Comments

hardcoar picture hardcoar  路  3Comments

AlStar01 picture AlStar01  路  3Comments

c0debreaker picture c0debreaker  路  4Comments

higimo picture higimo  路  3Comments