LinbuduLab/esbuild-plugins

Feature request: Copy individual file to different filename

jrmyio opened this issue · 5 comments

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.

This is supported in latest version 1.0.1 now.

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).

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.

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.

Should got fixed in 2.0.2 now.