Dynamic.yaml - how to keep variables outside the yaml?

I have docker-compose.yaml for traefik and it reads the .env for variables .
it is working with no issue .

Now i added dynamic.yaml and it seems it can't see the variable from .env.
Not sure if that supported or how i can enable it .

Tried:
traefik compose file:

services:


  traefik:
    image: traefik:latest
    **env_file:**
**      - .env**    
   .....

    volumes:
      - ./traefik/dynamic.yaml:/dynamic.yaml
    labels:
      traefik.enable: true

dymanic.toml

http:
  routers:


    service-router-frigate:
      entryPoints:
        - websecure
      middlewares:
        - frigate-auth        
      service: service-frigate
      rule: Host(`xxx.${DOMAINNAME}`)
      tls:
        certResolver: myresolver

        
  services:

    service-frigate:
        ...

  middlewares:
    frigate-auth:
      basicAuth:
        users:
           - "${NVR_USER}:${NVR_PASS}"
```






```

AFAIK docker compose is doing the variable substitution in the compose file, other files are not processed, therefore can’t use env vars.