LinbuduLab / esbuild-plugins

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

Feature request: Copy individual file to different filename #68

Closed jrmyio closed 1 year ago

jrmyio commented 2 years ago

I am trying to move from webpack-copy-plugin to esbuild-plugin-copy.

However one of the things that currently doesn't seem supported is copying a file from for example hello.txt to world.txt. It instead creates a world.txt directory.

linbudu599 commented 2 years ago

This is supported in latest version 1.0.1 now.

jrmyio commented 2 years ago

It seems that when I specify a resolveFrom to an absolute dir, and have assets configured to something like this : [{ .... to: './test.js', }],

It still tries to make a folder test.js. This seems to be not the case when you use out or cwd as resolveFrom.

On a side note, I started messing with resolveFrom as an absolute dir because using cwd seemed to be ignoring the out directory (it just uses the cwd) when the from uses a single star (for example /test/abc/*.js).

linbudu599 commented 2 years ago

This was fixed now in 1.2.1, which is indeed a mistake.

Also, option resolveFrom is not actually designed to solve the file naming problem, but to control the destination resolve, I used another separate piece of code logic to solve the independent file naming problem.

A new option dryRun was introduced to avoid unexpected cases which may make your project folders a mess.

jrmyio commented 1 year ago

After upgrading from 1.3 to the new version, trying to copy a single filename to a different filename again creates a directory rather than a file.

linbudu599 commented 1 year ago

Should got fixed in 2.0.2 now.