fastify / fastify-vite

Fastify plugin for Vite integration.
MIT License
879 stars 73 forks source link

If vites config contains `defineConfig` with callback, then SSR is broken #111

Closed PredokMiF closed 1 year ago

PredokMiF commented 1 year ago

Prerequisites

Fastify version

4.17.0

Plugin version

4.0.0

Node.js version

16.18.1

Operating system

Windows

Operating system version (i.e. 20.04, 11.3, 10)

10 Pro (21H2)

Description

In vite.config.js I need to generate config for different goals. vite can help with this case and front build is Ok, but when I start http-server with the plugin - it fails, cause in next code https://github.com/fastify/fastify-vite/blob/568e178a10768211944bfc1aaf6e57a6a091693d/packages/fastify-vite/config.js#L173 we try to make Object.assign(<function>, <object>), where <function> is config-function from vite.config.js

Steps to Reproduce

  1. Get any react SSR example (not SPA) like https://github.com/fastify/fastify-vite/tree/dev/examples/react-hydration
  2. Open vite.config.js
  3. Modify export like this
    import { defineConfig } from 'vite'
    //...
    export default defineConfig((config) => {
    return ({ root, plugins })
    })

Expected Behavior

No issue

galvez commented 1 year ago

Think this is already fixed, need to add a test and push out the new release. Will double check.

PredokMiF commented 1 year ago

This is great news because this bug breaks my build and I had to add a lot of hacks. I'm really looking forward to the release.

PredokMiF commented 1 year ago

In which branch can I see the fixed code?