LinbuduLab / esbuild-plugins

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

Destination directory is not recursively created if 'to' asset path is not a directory #99

Open KKoukiou opened 1 year ago

KKoukiou commented 1 year ago

I have an asset that looks like this: { from: '/home/kkoukiou/repos/cockpit/node_modules/@patternfly/patternfly/assets/fonts/RedHatFont-updated/RedHatText/RedHatText-updated-Bold.woff2', to: '/home/kkoukiou/repos/cockpit/dist/static/fonts/RedHatText-Bold.woff2'", }

The ./dist/static/fonts directory does not exist and therefore the plugin fails with: text: "ENOENT: no such file or directory, copyfile ...

If I use directory for the 'to' path it works, but I need to rename the asset so this is not a solution.

I believe this conditional directory creation could be removed https://github.com/LinbuduLab/esbuild-plugins/blob/a3df3e2798669801dd8aef537a46ad24d8df60ae/packages/esbuild-plugin-copy/src/lib/handler.ts#L77

linbudu599 commented 1 year ago

Could u please try the way as #100 first? It seems like you're both using absolute paths.

KKoukiou commented 1 year ago

@linbudu599 hi, I meantioned above, 'If I use directory for the 'to' path it works, but I need to rename the asset so this is not a solution.'

linbudu599 commented 1 year ago

This should be fixed in 2.1.1, the dir only condition was removed so it works fine now, please try again.

martinpitt commented 1 year ago

Excellent, works fine @linbudu599 . Thank you!