Skip to content

Conversation

@Imran-imtiaz48
Copy link

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.

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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant