Skip to content

IOEXT-2183: fix: reload config after pre-app hooks and default --web-optimize from NODE_ENV (CEXT-6815) - #942

Open
iivvaannxx wants to merge 1 commit into
adobe:masterfrom
iivvaannxx:ensure-reload-env-before-commands
Open

iivvaannxx wants to merge 1 commit into
adobe:masterfrom
iivvaannxx:ensure-reload-env-before-commands

Conversation

@iivvaannxx

@iivvaannxx iivvaannxx commented Sep 29, 2026 •

Copy link
Copy Markdown
Contributor

Description

Two changes:

  1. Reload config after every pre-app hook. Hooks can write to .env, but only run and the deploy-actions path reloaded config afterwards. aio-lib-core-config is now reloaded after:

    • pre-app-build in app build, which app deploy also runs
    • the pre-deploy hooks in app deploy, so DB auto-provisioning and the web deploy see the new values
    • pre-app-undeploy in app undeploy
    • pre-app-build and pre-app-deploy in src/lib/build-actions.js and src/lib/deploy-actions.js, which app run uses when action files change
  2. --web-optimize defaults from NODE_ENV. The flag no longer defaults to false. When you don't pass it, the web build is optimized if NODE_ENV=production. The value is read at build time, after the pre-app-build reload, so NODE_ENV from .env is respected. --no-web-optimize is now available to turn optimization off in production.

Related Issue

IOEXT-2183 (blocks CEXT-6815)

Companion PR: adobe/aio-lib-web#248 (Parcel mode from NODE_ENV in aio-lib-web)

Motivation and Context

Values that pre-app hooks wrote to .env were ignored by later steps, and production web builds were never minified unless you passed the flag.

How Has This Been Tested?

  • The touched suites (app/build, app/deploy, app/undeploy, app/run, lib/build-actions, lib/deploy-actions) pass: 206 tests, 10 of them new. The new tests check that the reload happens after the pre-hook and before the next step, and cover each --web-optimize/NODE_ENV combination.
  • eslint src test is clean.
  • On a fresh npm install of current master, 107 unrelated tests fail locally both with and without this change.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • I have signed the Adobe Open Source CLA.
  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly. (README flag text is regenerated by oclif readme on version)
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

@codecov

codecov Bot commented Sep 29, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@iivvaannxx iivvaannxx changed the title fix: reload config after pre-app hooks and default --web-optimize from NODE_ENV (CEXT-6815) IOEXT-2183: fix: reload config after pre-app hooks and default --web-optimize from NODE_ENV (CEXT-6815) Sep 29, 2026
@aroragarvit666-hue

Copy link
Copy Markdown

@sandeep-paliwal, @iivvaannxx -- For someone who has added pre-hooks changing .env in their app, this would be a sudden behaviour change, right ? Do you think this should be activated with an additional flag in the command ? So that it doesn't break anything ?

Same with web-optimize. Why to make it automatic for Production apps ? Although, I agree this doesn't seem to bring any functional impact on the apps so not much concerned about this.

@iivvaannxx

Copy link
Copy Markdown
Contributor Author

@aroragarvit666-hue I get your point, but pre-hooks are not a user-invoked command that we can add a flag to :(

They are invoked automatically via the aio CLI. Maybe we could add an env var like AIO_RELOAD_ENV_ON_HOOKS and only do this if that value is truthy. Another option is to accept it's a behavior change and release a major, which I would not see as a problem either. I did a similar change in the past in #906 in case you want to check what the past team did with it.

The web-optimize change is probably unnecessary, given that aio-lib-web now sets production via NODE_ENV (see PR). I believe web-optimize is the default in that mode. I would keep it just in case, though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants