Comments (15)
Yo~! serve
is actually being removed going forward since it's the largest dependency, least-commonly used, and is really only used for test service workers in a production setting.
We'll include good/better documentation as to how achieve the same actions going forward π
from preact-cli.
Here is my understanding:
npm start
(or preact watch or npm run dev) - run it during development. Supports hot-reloading, and a few other goodies. Basically, whenever you change a code, the browser immediately displays the new changes without having to manually reload the browser.npm run build
(or preact build) - create production ready code inside the build foldernpm run serve
(or preact build + preact serve) - build and run production-like serverpreact serve
- run production-like server (without build)
from preact-cli.
Sorry to revive this old issue. I am studying up on Preact CLI but there is this one aspect I cannot yet wrap my head around and this issue most closely describes it.
If preact serve
is used to test the build, but not really intended for production, then how do we deploy it to production? Because I cannot really find the code in the default project that starts the server. Are we supposed to say, add Express and create a server.js
file that then uses the App
component? This part is not clear to me yet and I cannot find any docs on it.
from preact-cli.
After you build you are responsible for deploying and serving the generated build
folder (which is a static webapp).
from preact-cli.
@oren You can use it after run preact build
to see the production version of your site before deploying. Many thing is only enable on production (for now) like Service worker, HTTP2 server push, ...
from preact-cli.
The command preact serve
is the one you would want to use during development. It supports hot-reloading, and a few other goodies. Basically, whenever you change a code, the browser immediately displays the new changes without having to manually reload the browser.
from preact-cli.
@marvinhagemeister Actually serve
is the production-like server. What you described is preact watch
(which is npm run dev
by default). π
I've made that mistake too.
from preact-cli.
@lukeed oh shoot! That is embarrassing π
from preact-cli.
@oren that is 100% correct
@marvinhagemeisterΒ No it's not -- don't worry about it! π
from preact-cli.
One addendum: currently, npm start
will actually check the NODE_ENV
environment variable. If it is set to "production"
, it will run npm run serve
. If it's any other value, it will run npm run dev
(the development server).
There was some question around this, and I think that's warranted - it's probably worth making sure we're doing the best possible thing here. For my own purposes, I know a lot of hosts assume npm i && npm start
will produce a running production server, so I wanted to have that work out-of-the-box for things like now.sh.
from preact-cli.
@developit what is the preferred way of hosting preact app in production? npm run serve
uses simplehttp2server
but simplehttp2server
itself says This server is for development purposes only.
.
How to take advantage of http2 push when preact app is hosted behind a proxy like Nginx
from preact-cli.
@kuldeepkeshwar nginx itself doesn't support http2 push so you can't do anything about it.
There are many option to host a static sites with h2 push support.
- use cdns, like cloudflare, they support h2 push by sending the right header
- static hosting service like netlify, firebase hosting, ...
from preact-cli.
from preact-cli.
preact serve
is used for testing the production build locally where you can test the lighthouse scores, check if there are any performance related issue or not.
from preact-cli.
My confusion is that I did not realize the default template gives a client-side only app. Now it makes sense. Thanks!
from preact-cli.
Related Issues (20)
- compilingβ ERROR Error: Babel-loader config not found!!! HOT 9
- Pages duplicate when accessing with /index.html HOT 9
- Brotli build - outputs content to same filename HOT 4
- default project template doesn't work with Node v18 HOT 4
- ERROR Error: error:0308010C:digital envelope routines::unsupported HOT 1
- Duplicated content when using /routes when using CLI v4 HOT 5
- Homepage content loaded on all non-prerendered pages HOT 3
- Add Typescript increasses the bundle size HOT 4
- Can't resolve 'preact-cli-entrypoint' HOT 4
- Exported rest param syntax functions create invalid build JS HOT 4
- preact-cli hangs after "β Done!" HOT 5
- CSS source maps missing in build output HOT 3
- Typescript v5.1.6 compatibility HOT 2
- Route code-splitting breaks lazy loading of images HOT 3
- Use esbuild instead of babel HOT 2
- Fail to build due to `property missing ':'` when inline style HOT 4
- "TypeError: Cannot read properties of undefined (reading 'call')" when trying to route split HOT 7
- OptimizeCssAssetsPlugin causes build to crash in Yarn PnP mode HOT 2
- Config file failure when adding plugins HOT 8
- build gets stuck at "after chunk asset optimization" HOT 11
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. πππ
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from preact-cli.