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

feat: add support for target path transforms (options.transformPath) #115

Closed
wants to merge 1 commit into from

Conversation

patkec
Copy link

@patkec patkec commented Feb 12, 2017

Added a new function, transformPath, with which the target path can be modified programmatically. Decided to keep the functionality of to param unmodified so that path transfformation can be combined with templates for ease of use.
Should resolve #107.

@michael-ciniawsky michael-ciniawsky changed the title Add support for target path transform feat: add support for target path transform (options.transformPath) Oct 5, 2017
@michael-ciniawsky
Copy link
Member

@patkec Could you please rebase to latest master and without looking at the current implementation I wonder if it would be possible to accept a {Function} on already existing options/interfaces instead of adding a new option ?

@jsf-clabot
Copy link

jsf-clabot commented Oct 5, 2017

CLA assistant check
All committers have signed the CLA.

@patkec
Copy link
Author

patkec commented Oct 5, 2017

Rebased. As for the implementation, the only option that would be suitable is to, but then we would lose the possibility to use templates. I thought it nice that users could specify a template in to and still do some path processing after.

@michael-ciniawsky michael-ciniawsky added this to the 4.2.0 milestone Oct 5, 2017
@michael-ciniawsky michael-ciniawsky changed the title feat: add support for target path transform (options.transformPath) feat: add support for target path transforms (options.transformPath) Oct 5, 2017
@michael-ciniawsky
Copy link
Member

Can you give a small example for to and the loss of templates ? The implementation is fine, but we need to carefully triage the API design, since every added option is likely to stay for a while :)

@patkec
Copy link
Author

patkec commented Oct 6, 2017

It seemed like a good idea at the time, but cannot really think of a good example right now. Will think about it over the weekend and get back to you.

@patkec
Copy link
Author

patkec commented Oct 10, 2017

Thinking a bit about this, the only benefit of having both templates and a transform is that templates support content hashing. Everything else should be fairly easy to implement in the transform function, if needed.
No idea how often this hash option is used and if it is worth introducing a special transformPath option because of it.

@michael-ciniawsky
Copy link
Member

@evilebottnawi We should find consensus on this if possible. I'm -0 atm

@FireController1847
Copy link

FireController1847 commented Apr 21, 2018

If you want, I can provide an example usage for this.

Let's say I want to copy all of my html files to my dist folder. When I do this currently:

    new CopyWebpackPlugin([
      { from: 'src/*.html',
        to: './'
    ], { debug: 'info' })

This will make a new folder in dist called src, and THEN put my html files in that. I could use this by doing something like this:

    new CopyWebpackPlugin([
      { from: 'src/*.html',
        to: './',
        transform: function(content, filePath) {
          return path.resolve(filePath, '..');
        } }
    ], { debug: 'info' })

But currently this does not work since we can't transform the path of a file, YET.

@kdelmonte
Copy link

Any idea when this will be released?

@alexander-akait
Copy link
Member

Need rebase

Fetz added a commit to Fetz/copy-webpack-plugin that referenced this pull request Aug 28, 2018
@alexander-akait
Copy link
Member

Close in favor #284

Fetz added a commit to Fetz/copy-webpack-plugin that referenced this pull request Oct 7, 2018
Fetz added a commit to Fetz/copy-webpack-plugin that referenced this pull request Oct 11, 2018
Fetz added a commit to Fetz/copy-webpack-plugin that referenced this pull request Oct 20, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Feature] Manually modify output path
7 participants