Skip to content

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

Closed
patkec wants to merge 1 commit into
webpack:masterfrom
patkec:master
Closed

feat: add support for target path transforms (options.transformPath)#115
patkec wants to merge 1 commit into
webpack:masterfrom
patkec:master

Conversation

@patkec

@patkec patkec commented Feb 12, 2017

Copy link
Copy Markdown

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
Copy Markdown
Contributor

@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

jsf-clabot commented Oct 5, 2017

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@patkec

patkec commented Oct 5, 2017

Copy link
Copy Markdown
Author

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
Copy Markdown
Contributor

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

patkec commented Oct 6, 2017

Copy link
Copy Markdown
Author

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

patkec commented Oct 10, 2017

Copy link
Copy Markdown
Author

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
Copy Markdown
Contributor

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

@FireController1847

FireController1847 commented Apr 21, 2018

Copy link
Copy Markdown

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
Copy Markdown

Any idea when this will be released?

@alexander-akait

Copy link
Copy Markdown
Member

Need rebase

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

Copy link
Copy Markdown
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