.env.local.production

In frameworks like Next.js (versions 9.4 through 12) and certain custom Webpack setups, the naming convention followed a specific pattern:

NODE_ENV.local

Therefore, if your NODE_ENV was set to production, the framework would look for .env.production.local. .env.local.production

However, due to developer confusion or legacy configuration scripts, you will occasionally find the inverted version: .env.local.production .

This file is interpreted as:

GitHub Actions or GitLab CI often run next build in a production environment but need a build-time secret that differs from runtime.

# .github/workflows/deploy.yml
- name: Create .env.production.local
  run: |
    echo "BUILD_CACHE_TOKEN=$ secrets.CI_TOKEN " > .env.production.local
    npm run build

Sometimes, the process of building your application (minification, bundling, tree-shaking) requires specific flags. For example, you might enable source maps only in local production builds, but not in real production. In frameworks like Next

# Real production (on the server)
GENERATE_SOURCEMAP=false
LOG_LEVEL=error

The most critical aspect of .env.local.production is security.