webpack-contrib/copy-webpack-plugin

Examples of patterns are confusing

scott-ln opened this issue · 8 comments

Documentation Is:

  • Missing
  • Needed
  • Confusing
  • Not Sure?

Please Explain in Detail...

The plugin's signature is described as containing:

      patterns: [
        { from: "source", to: "dest" },
        { from: "other", to: "public" },
      ],

This implies that a "pattern" is an object with from and to values. But in the section titled webpack.config.js the following example is given:

      patterns: [
        "relative/path/to/file.ext",
        "relative/path/to/dir",
        path.resolve(__dirname, "src", "file.ext"),
        path.resolve(__dirname, "src", "dir"),
        "**/*",
        {
          from: "**/*",
        },
        path.posix.join(
          path.resolve(__dirname, "src").replace(/\\/g, "/"),
          "*.txt"
        ),
      ],

What are these strings for? Are they sources or destinations, and what distinguishes those?

Your Proposal for Changes

Please explain the above more clearly in the documentation. Thank you.

By default we copy files in your output.path (i.e. dist directory), if you need to change path you need to use { from: "source", to: "dest" }

I'm afraid I still don't understand from your reply whether those strings are sources or destinations. Would you please update the documentation to make it clear? I'm not just asking for myself but anyone else who might have the same question.

I don't understated what you don't understand, please clarify

What are these strings for? Are they sources or destinations, and what distinguishes those?

Source, for any copy tools you provide firstly source of files

Here files/directories/globs

OK, thank you, that is clear. May I suggest that you update the description of the plugin's signature, at the start of the options section, to something like this?

      patterns: [
        { from: "source", to: "dest" },
        "path/to/source", // absolute or relative, files/directories/globs - see below for examples
      ],

Thanks again.

PR welcome, it is easy

Sorry, I can't. My employer's bureaucracy is incompatible with the CLA process required to make a pull request to this project.

Hello, it's me again. I don't work there any more and now have the time and energy to do things on my own account, so here's the PR.