Right now, the Codex build process involves several stages that build the same file multiple times, overwriting the result of the previous build. Specifically:
- The main library is built twice, once unminified in ESM format, and once minified in the CJS and UMD formats. These two builds produce non-overlapping JS files, but they produce the same CSS files. The first build produces unminified versions of the CSS files, the second build then overwrites them with minified versions.
- For all builds except the sandbox (the main library, the split library, and the search build) we run the build four times, with each build producing different CSS files (LTR, RTL, LTR legacy and RTL legacy). These four builds all produce the same JS files, which keep being overwritten with identical copies of each other. We had to disable the use of hashes in chunk file names, otherwise these four builds would not have been identical, which would have caused problems.
- Note that the split build also produces four copies of the manifest.json file, each with a different name and slightly different contents, because the names of the CSS files differ
We should explore using Vite plugins to improve this situation in some way. For the additional style builds, maybe we could suppress the generation of the JS files, or get one build to generate all 4 versions of the CSS files. For the different minification settings for different JS formats, maybe we could suppress the generation of the CSS files for the minified build, or build them but with different names, or build them all as one build but use some other way to prevent minification of the ESM build.