We are proud to announce a significant improvement to our developer experience: validation on output paths for static builds. As of today,
@now/static-buildvalidates a given
distDirconfiguration option, aborting a build if the output directory doesn't exist.
This seemingly simple validation step is incredibly important for multiple reasons. Read on as we detail the steps that led to this release.
Configuration Validation in Now
Rule #1 of Human-Computer Interaction (HCI) is to ensure that the user is always aware of the state of the system. As such, validation becomes increasingly important. Now validates a user's
now.jsonbefore anything else – syncing, uploading, or deploying – because incorrect data from the beginning leads to unfavorable results in the end.
@now/static-buildbuilds content in the cloud and serves the static built output. It typically assumes that the final built artifacts exist in a
distdirectory, but in some cases, build tools have different outputs:
static, for example.
Upon examining multiple reports of
404 Page Not Founderrors on apps deployed on Now, we were able to identify that the source of confusion around these errors was that the output directory specified by a user in
now.jsonsimply did not exist.
What was happening was that the builder would run to completion and then exit successfully, serving the contents of a non-existent directory. This would result in a
404when accessed. While this is expected behavior in the builder and not technically a bug, it can lead to outcomes that users do not expect in the event of an invalid
One particular case of this involves websites and applications deployed using our GitHub integration. Previously, a merge to
masterwould automatically deploy a website using
@now/static-buildand immediately alias it to a user's chosen aliases. This could sometimes lead to a surprising 404 on production in the event that the output directory was incorrectly configured.
With today's upgrade to
@now/static-build, this is no longer the case. The integration will abort, the check will fail, and the deployment will not occur. Your websites and applications stay up.
Developer experience is of the highest priority at ZEIT. We proudly aim to serve our developer community as best we can. It is our hope that the changes to
@now/static-builddo exactly this, and that our developers continue developing with the ease that they know and love from our tools. As always, we are open to your feedback, questions, concerns and praise. Feel free to reach out on Twitter.