You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
IOEXT-2183: fix: reload config after pre-app hooks and default --web-optimize from NODE_ENV (CEXT-6815) - #942
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
--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.
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)
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
@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.
@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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Two changes:
Reload config after every pre-app hook. Hooks can write to
.env, but onlyrunand the deploy-actions path reloaded config afterwards.aio-lib-core-configis now reloaded after:pre-app-buildinapp build, whichapp deployalso runsapp deploy, so DB auto-provisioning and the web deploy see the new valuespre-app-undeployinapp undeploypre-app-buildandpre-app-deployinsrc/lib/build-actions.jsandsrc/lib/deploy-actions.js, whichapp runuses when action files change--web-optimizedefaults fromNODE_ENV. The flag no longer defaults tofalse. When you don't pass it, the web build is optimized ifNODE_ENV=production. The value is read at build time, after thepre-app-buildreload, soNODE_ENVfrom.envis respected.--no-web-optimizeis now available to turn optimization off in production.Related Issue
IOEXT-2183 (blocks CEXT-6815)
Companion PR: adobe/aio-lib-web#248 (Parcel
modefromNODE_ENVin aio-lib-web)Motivation and Context
Values that pre-app hooks wrote to
.envwere ignored by later steps, and production web builds were never minified unless you passed the flag.How Has This Been Tested?
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_ENVcombination.eslint src testis clean.npm installof current master, 107 unrelated tests fail locally both with and without this change.Types of changes
Checklist:
oclif readmeon version)