0
Fork 0
mirror of https://github.com/withastro/astro.git synced 2024-12-23 21:53:55 -05:00
astro/.changeset/metal-pumas-walk.md
Matthew Phillips e55af8a232
Node.js standalone mode + support for astro preview (#5056)
* wip

* Deprecate buildConfig and move to config.build

* Implement the standalone server

* Stay backwards compat

* Add changesets

* correctly merge URLs

* Get config earlier

* update node tests

* Return the preview server

* update remaining tests

* swap usage and config ordering

* Update packages/astro/src/@types/astro.ts

Co-authored-by: Sarah Rainsberger <sarah@rainsberger.ca>

* Update .changeset/metal-pumas-walk.md

Co-authored-by: Sarah Rainsberger <sarah@rainsberger.ca>

* Update .changeset/metal-pumas-walk.md

Co-authored-by: Sarah Rainsberger <sarah@rainsberger.ca>

* Update .changeset/stupid-points-refuse.md

Co-authored-by: Sarah Rainsberger <sarah@rainsberger.ca>

* Update .changeset/stupid-points-refuse.md

Co-authored-by: Sarah Rainsberger <sarah@rainsberger.ca>

* Link to build.server config

Co-authored-by: Fred K. Schott <fkschott@gmail.com>
Co-authored-by: Sarah Rainsberger <sarah@rainsberger.ca>
2022-10-12 17:25:51 -04:00

1.2 KiB

@astrojs/node
major

Standalone mode for the Node.js adapter

New in @astrojs/node is support for standalone mode. With standalone mode you can start your production server without needing to write any server JavaScript yourself. The server starts simply by running the script like so:

node ./dist/server/entry.mjs

To enable standalone mode, set the new mode to 'standalone' option in your Astro config:

import { defineConfig } from 'astro/config';
import nodejs from '@astrojs/node';

export default defineConfig({
  output: 'server',
  adapter: nodejs({
    mode: 'standalone'
  })
});

See the @astrojs/node documentation to learn all of the options available in standalone mode.

Breaking change

This is a semver major change because the new mode option is required. Existing @astrojs/node users who are using their own HTTP server framework such as Express can upgrade by setting the mode option to 'middleware' in order to build to a middleware mode, which is the same behavior and API as before.

import { defineConfig } from 'astro/config';
import nodejs from '@astrojs/node';

export default defineConfig({
  output: 'server',
  adapter: nodejs({
    mode: 'middleware'
  })
});