protibimbok / django-vite-plugin

This plugin configures Vite for use with Django backend.
112 stars 14 forks source link

Setting custom host for resolveDevServerUrl #55

Closed maziar-dandc closed 4 months ago

maziar-dandc commented 5 months ago

Hi,

When using dockerized environments, we have to set host: true (aka 0.0.0.0 ipv4 / [::] ipv6) in vite config, to ensure docker container broadcasts their output, so it can be accessed by the host computer. This currently ends up making the .hotfile contain http://[::]:5173 which on linux works fine, but on windows it doesn't.

I tried doing this on my own by using config.define?._vite_custom_host (found out define doesn't like strings) and config.env?._vite_custom_host (didn't work, couldn't debug further cause I'm noob), so would appreciate some pointers on how to go about it.

image

protibimbok commented 4 months ago

Did you try this?

import { defineConfig } from "vite";
import { djangoVitePlugin } from "django-vite-plugin";

export default defineConfig({
    plugins: [djangoVitePlugin({
        input: [
            // entries
        ]
    })],
    server: {
        host: "0.0.0.0",
    }
});