Skip to content

sst dev should watch .env files and reload env vars without restart #6886

@guidefari

Description

@guidefari

Problem

Changes to .env or .env.<stage> do not take effect while sst dev is running.

Today the dev loop is:

  1. Edit .env
  2. Stop sst dev
  3. Start sst dev again
  4. Wait for the app to redeploy

It would be useful if SST could watch env files and trigger a redeploy automatically, the same way it already does for source/config changes.

Example

export default $config({
  app(input) {
    return {
      name: "my-app",
      removal: input?.stage === "production" ? "retain" : "remove",
      home: "aws",
      watch: {
        env: true,
      },
    };
  },
});

Then changing either of these files should trigger a redeploy:

.env
.env.dev

The next Pulumi/SST run should receive the updated env values.

Proposed API

Add an optional env flag to app.watch:

{
  app: {
    watch: {
      env: true,
    },
  },
}

Default should probably be false to avoid changing existing behaviour.

Why this would help

This removes a common restart/redeploy cycle during local development.

For apps that use env vars in sst.config.ts or component config, tweaking local config/secrets would become part of the normal sst dev feedback loop instead of requiring a manual restart.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions