Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using astro with @astrojs/netlify does not allow running preview locally #491

Open
1 task
richwklein opened this issue Dec 21, 2024 · 1 comment
Open
1 task

Comments

@richwklein
Copy link

Astro Info

Astro                    v5.1.1
Node                     v20.16.0
System                   macOS (x64)
Package Manager          npm
Output                   static
Adapter                  @astrojs/netlify
Integrations             astro-icon
                         astro-fuse
                         @astrojs/mdx
                         @astrojs/sitemap
                         @astrojs/tailwind

Describe the Bug

I'm using the netlify adapter. When I try to run the astro preview command locally, I get the error.

The @astrojs/netlify adapter does not support the preview command.

What's the expected result?

I would expect I would be able to run preview locally to test the output of the build locally.

Link to Minimal Reproducible Example

https://stackblitz.com/edit/github-ggno1pvr?file=astro.config.mjs

Participation

  • I am willing to submit a pull request for this issue.
@LarsEjaas
Copy link

LarsEjaas commented Jan 4, 2025

I am seeing the same. Right now I am using the node-adaptor as a temporary workaround:

in my astro.config.mjs file:

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

let adapter = netlify({
  edgeMiddleware: false,
  functionPerRoute: false,
});

if (process.argv[3] === '--node' || process.argv[4] === '--node') {
  adapter = node({ mode: 'standalone' });
}

// https://astro.build/config
export default defineConfig({
  adapter,
 //--more config

In my package.json I then have a build command I only use locally - with a --node flag:

"scripts": {
    "dev": "netlify dev",
    "start": "astro dev",
    "build": "npm ci --include=dev && astro check && astro build",
    "build:node": "npm ci --include=dev && astro check && astro build ./ --node",
    "preview": "astro preview --node",

This runs on http though - and right now causes a few issues to me - so kind of a pain. I had no issues previously running the preview command using the netlify-adaptor v5.5.4 - but fails on v6.0.1

Edit: I have switched to using the Netlify CLI locally where I can run netlify serve - this runs a local build and then serves a preview locally in the same way as netlify preview used to work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants