Improving Builds with Postbuild Scripts
Learn how we can improve our Astro builds with postbuild scripts.
We'll cover the following
Astro’s default build process takes care of many things to improve the final production version of an Astro application. However, sometimes, we might need extra custom steps that can only be achieved through the use of postbuild scripts. These scripts are custom JavaScript files that run after the build process, therefore the name postbuild scripts. In this lesson, we’ll take a look at how to create a postbuild script that also performs common cleanup processes after Astro’s default build process.
The build script
To create postbuild steps, we need to create a separate build script that executes code after the astro build
command finishes running. In the following code widget, we’ll find a build.js
file inside the scripts
folder. Inspect the contents of the file in the following widget:
Get hands-on with 1400+ tech skills courses.