LinbuduLab / esbuild-plugins

ESBuild plugins by @LinbuduLab
MIT License
113 stars 18 forks source link

Add transform option to plugin #113

Open darthgoldstein opened 1 month ago

darthgoldstein commented 1 month ago

The idea here is to make the plugin a bit more robust by the allowing the user of the plugin to transform the file along the way when copying.

The way I envision this field is that its value will be a callback with the file file path and content as its parameters. It will return the content that will be copied to the to destination.

{
    from: string;
    to: string;
    transform: (fromPathResolved: string, fileContent: Buffer) => string | Buffer;
}
darthgoldstein commented 1 month ago

I opened a pull request for this feature. Please take a look and give me some feedback.