mirror of
https://github.com/withastro/astro.git
synced 2024-12-23 21:53:55 -05:00
e55af8a232
* 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>
43 lines
1.2 KiB
Markdown
43 lines
1.2 KiB
Markdown
---
|
|
'@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:
|
|
|
|
```shell
|
|
node ./dist/server/entry.mjs
|
|
```
|
|
|
|
To enable standalone mode, set the new `mode` to `'standalone'` option in your Astro config:
|
|
|
|
```js
|
|
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.
|
|
|
|
```js
|
|
import { defineConfig } from 'astro/config';
|
|
import nodejs from '@astrojs/node';
|
|
|
|
export default defineConfig({
|
|
output: 'server',
|
|
adapter: nodejs({
|
|
mode: 'middleware'
|
|
})
|
|
});
|
|
```
|