Recently, in a project using esbuild, I found myself wanting to rename a file after the build process finished.
The problem was, I was using esbuild-sass-plugin to compile the scss files scattered around my project into a single css file, and I couldn’t figure out how to customise the output filename that it used. This may have been a lack of knowledge on my part, but either way, it output a file called main.css that I needed to be styles.css.
So… I wrote myself a super basic esbuild plugin that simply waits until the build has finished and then renames the output file. Not the most elegant solution but one that worked to get me back to working on my actual project.
You’ll find the code below.


