Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Copy fails after first from #105

Open
joeworkman opened this issue Aug 21, 2023 · 2 comments
Open

Copy fails after first from #105

joeworkman opened this issue Aug 21, 2023 · 2 comments

Comments

@joeworkman
Copy link

joeworkman commented Aug 21, 2023

I have a very simple setup with copy. I just want to copy 2 files into a folder.

copy({
    assets: {
        from: [
            "node_modules/jquery/dist/jquery.min.js",
            "node_modules/what-input/dist/what-input.min.js"
        ],
        to: [ "js/vendor" ]
    },
})

However, it always fails when processing the 2nd file. If I switch the order of the files, it still fails on the 2nd one. I did a verbose output and got this.

i Resolve assert pair to path from: /Users/joeworkman/Developer/proton-sites-template/dist/assets
i Watching mode disabled. You need to enable build.watch option for watch mode to work.
i The from path node_modules/jquery/dist/jquery.min.js,node_modules/what-input/dist/what-input.min.js of current asset pair doesnot ends with /**/*(.ext), 
i File copied: /Users/joeworkman/Developer/proton-sites-template/node_modules/jquery/dist/jquery.min.js -> /Users/joeworkman/Developer/proton-sites-template/dist/assets/js/vendor/jquery.min.js
i The from path node_modules/jquery/dist/jquery.min.js,node_modules/what-input/dist/what-input.min.js of current asset pair doesnot ends with /**/*(.ext), 
ERR > /Users/joeworkman/Developer/proton-sites-template/node_modules/esbuild/lib/main.js:1649
  let error = new Error(text);
              ^
@joeworkman
Copy link
Author

This works but it seems a bit ridiculous that I should have to do this.

        copy({ assets: {
            from : "node_modules/jquery/dist/jquery.min.js",
            to   : "js/vendor"
        }}),
        copy({ assets: {
            from : "node_modules/what-input/dist/what-input.min.js",
            to   : "js/vendor"
        }}),

@abiencourt
Copy link

@joeworkman a little cleaner approach (avoids to call twice the plugin)

const esbuildConfig = {
  plugins: [
    copy({
      assets: [
        {
          from: ["node_modules/jquery/dist/jquery.min.js"],
          to: ["js/vendor"],
        },
        {
          from: ["node_modules/what-input/dist/what-input.min.js"],
          to: ["js/vendor"],
        },
      ],
    }),
  ],
};

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants