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 #13180

Closed
1 task
richwklein opened this issue Dec 21, 2024 · 4 comments
Closed
1 task
Labels
needs triage Issue needs to be triaged pkg: netlify Related to the Netlify adapter

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.

@ematipico ematipico added the pkg: netlify Related to the Netlify adapter label Feb 7, 2025
@ematipico ematipico transferred this issue from withastro/adapters Feb 7, 2025
@github-actions github-actions bot added the needs triage Issue needs to be triaged label Feb 7, 2025
@ematipico
Copy link
Member

That's expected. The netlify adapter doesn't provide a preview command. You might want to evaluate the netlify CLI for that. Closing

@ematipico ematipico closed this as not planned Won't fix, can't repro, duplicate, stale Feb 12, 2025
@richwklein
Copy link
Author

Well who maintains the adapter and how can we ask them to provide a preview command then? The two repos that hold the netlify adapters are both showing as archived as far as I can tell.

@ematipico
Copy link
Member

ematipico commented Feb 13, 2025

@richwklein the packages have been moved here, in the main monorepo. That's written in the main readme of the adapters repository.

I closed the issue because it's not a bug. You're still free to send a PR if you think it's a good addition

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs triage Issue needs to be triaged pkg: netlify Related to the Netlify adapter
Projects
None yet
Development

No branches or pull requests

3 participants