diff options
author | 2022-10-12 17:25:51 -0400 | |
---|---|---|
committer | 2022-10-12 17:25:51 -0400 | |
commit | e55af8a23233b6335f45b7a04b9d026990fb616c (patch) | |
tree | 62f47ae6e1fa56c04c045318c3a0d34674cb4a63 /packages/integrations/image/src | |
parent | 2b7fb848bbe18942960c17a135c5a3769780512b (diff) | |
download | astro-e55af8a23233b6335f45b7a04b9d026990fb616c.tar.gz astro-e55af8a23233b6335f45b7a04b9d026990fb616c.tar.zst astro-e55af8a23233b6335f45b7a04b9d026990fb616c.zip |
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>
Diffstat (limited to 'packages/integrations/image/src')
-rw-r--r-- | packages/integrations/image/src/index.ts | 21 |
1 files changed, 17 insertions, 4 deletions
diff --git a/packages/integrations/image/src/index.ts b/packages/integrations/image/src/index.ts index 3aaf27315..46b14b6b8 100644 --- a/packages/integrations/image/src/index.ts +++ b/packages/integrations/image/src/index.ts @@ -1,4 +1,4 @@ -import type { AstroConfig, AstroIntegration, BuildConfig } from 'astro'; +import type { AstroConfig, AstroIntegration } from 'astro'; import { ssgBuild } from './build/ssg.js'; import type { ImageService, SSRImageService, TransformOptions } from './loaders/index.js'; import type { LoggerLevel } from './utils/logger.js'; @@ -12,6 +12,11 @@ export { getPicture } from './lib/get-picture.js'; const PKG_NAME = '@astrojs/image'; const ROUTE_PATTERN = '/_image'; +interface BuildConfig { + client: URL; + server: URL; +} + interface ImageIntegration { loader?: ImageService; defaultLoader: SSRImageService; @@ -42,6 +47,7 @@ export default function integration(options: IntegrationOptions = {}): AstroInte let _config: AstroConfig; let _buildConfig: BuildConfig; + let needsBuildConfig = false; // During SSG builds, this is used to track all transformed images required. const staticImages = new Map<string, Map<string, TransformOptions>>(); @@ -67,8 +73,8 @@ export default function integration(options: IntegrationOptions = {}): AstroInte name: PKG_NAME, hooks: { 'astro:config:setup': async ({ command, config, updateConfig, injectRoute }) => { + needsBuildConfig = !config.build?.server; _config = config; - updateConfig({ vite: getViteConfiguration() }); if (command === 'dev' || config.output === 'server') { @@ -88,8 +94,15 @@ export default function integration(options: IntegrationOptions = {}): AstroInte defaultLoader, }; }, - 'astro:build:start': async ({ buildConfig }) => { - _buildConfig = buildConfig; + 'astro:config:done': ({ config }) => { + _config = config; + _buildConfig = config.build; + }, + 'astro:build:start': ({ buildConfig }) => { + // Backwards compat + if(needsBuildConfig) { + _buildConfig = buildConfig; + } }, 'astro:build:setup': async () => { // Used to cache all images rendered to HTML |