Update index.js #1
Open
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.
I replaced all callback-based fs functions with the modern fs/promises API so that everything runs with async/await, making the flow much cleaner and easier to follow. Instead of manually repeating and hardcoding paths, I used path.join consistently for building directory and file paths, which makes the code more portable. For the assets copying, I rewrote the logic into a proper recursive function that copies entire directories and files without first deleting everything, which is both safer and more efficient. In the CSS build step, instead of appending to the file repeatedly with fs.appendFile, I now read all .css files into memory, combine them with join("\n"), and write them once, which reduces I/O operations and keeps the file clean. The HTML building logic was also streamlined: placeholders are replaced with component content using a loop that clearly matches component names to placeholders, making it easy to maintain. Finally, I wrapped the whole build process in a structured build() function with proper try/catch error handling and added a success log message, so the build process feels more like a single controlled workflow.