vite-bundle: The configuration in 'pentatrion_vite.yaml' doesn't work with Docker

Hello

Thanks for your bundle.

I tried to use it with Docker, but I have some issue. To work with docker, I have to define a host in ‘vite.config.js’ :

export default defineConfig({
    plugins: [react(), symfonyPlugin()],
    build: {
        rollupOptions: {
            input: {
                app: "./assets/App.tsx",
            },
        },
    },
    server: {
        port: 3000,
        host: '0.0.0.0',
    },
});

But if I do that, the generated entrypoint.json don’t work anymore, because the host will be now ‘0.0.0.0’ instead of 'localhost

{
  "isProd": false,
  "viteServer": {
    "origin": "http://0.0.0.0:3000",
    "base": "/build/"
  },
  "entryPoints": {
    "app": {
      "js": [
        "http://0.0.0.0:3000/build/assets/App.tsx"
      ]
    }
  },
  "assets": null
}

I tried to add this in config/packages/pentatrion_vite.yaml

pentatrion_vite:
    server:
        host: localhost
        port: 3000
        https: false

But it didn’t work

The only solution I found is to add 'origin: ‘http://localhost:3000’ in Vite config

export default defineConfig({
    plugins: [react(), symfonyPlugin()],
    build: {
        rollupOptions: {
            input: {
                app: "./assets/App.tsx",
            },
        },
    },
    server: {
        origin: 'http://localhost:3000',
        port: 3000,
        host: '0.0.0.0',
    },
});

And I removed the pentatrion_vite.yaml (this file didn’t work)

Now, the entrypoints.json is OK, and everything is working fine with Docker.

I spend a lot of time to figure why this bundle didn’t work with Docker, so if this issue can help someone else who struggle to use this bundle with docker.

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 18 (9 by maintainers)

Most upvoted comments