nx-plugins icon indicating copy to clipboard operation
nx-plugins copied to clipboard

[esbuild-plugin-copy] Copy `to` path not working as expected

Open theo-staizen opened this issue 2 years ago • 1 comments

I am trying to copy some assets files from an npm package into ./dist/assets

import { build } from 'esbuild';
import { copy } from 'esbuild-plugin-copy';

await build({
  entryPoints: ['./src/index.ts'],
  bundle: true,
  format: 'esm',
  outfile: './dist/index.js',
  plugins: [
    copy({
      verbose: true,
      resolveFrom: 'out',
      assets: [
        {
          from: './node_modules/some-package/dist/esm/*.worker*.js',
          to: './assets/' // still copies files into ./dist
        }
      ]
    })
  ],
}).catch(() => process.exit(1));

Instead of copying to ./dist/assets it copies to ./dist. Here is the verbose output:

i Resolve assert pair to path from: /Users/.../esbuild/dist

i Use Merge-Structure for current assets pair.
i File copied: /Users/.../dist/esm/format.worker-28fe4aab.js -> /Users/.../esbuild/dist/format.worker-28fe4aab.js
i File copied: /Users/.../dist/esm/format.worker-51010d22.js -> /Users/.../esbuild/dist/format.worker-51010d22.js

If I try to use to: './dist/assets' it copies to ./dist/dist instead.

i Resolve assert pair to path from: /Users/.../esbuild/dist

i Use Merge-Structure for current assets pair.
i File copied: /Users/.../dist/esm/format.worker-28fe4aab.js -> /Users/.../esbuild/dist/dist/format.worker-28fe4aab.js
i File copied: /Users/.../dist/esm/format.worker-51010d22.js -> /Users/.../esbuild/dist/dist/format.worker-51010d22.js

I have no idea what's happening...

theo-staizen avatar Sep 14 '22 06:09 theo-staizen

Maybe you should use to: './assets' instead of to: './assets/'?

linbudu599 avatar Oct 02 '22 09:10 linbudu599

This still happens for me without a trailing slash.

powerc9000 avatar Jan 05 '23 17:01 powerc9000