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

transform support #4

Open
troy351 opened this issue Feb 26, 2022 · 10 comments · Fixed by #11
Open

transform support #4

troy351 opened this issue Feb 26, 2022 · 10 comments · Fixed by #11
Labels
enhancement New feature or request PR welcome

Comments

@troy351
Copy link

troy351 commented Feb 26, 2022

Hey, thanks for making this plugin, would it support transform (i.e. modify file contents) like rollup-plugin-copy and CopyWebpackPlugin ?

@sapphi-red sapphi-red added the enhancement New feature or request label Feb 26, 2022
@irnnr
Copy link

irnnr commented Apr 1, 2022

+1, this is a requirement for me as well as I transform xml to json during build and would like to have this in dev mode as well.

edit: looking at the source for rollup-plugin-copy it seems simple enough to do. I need to finish a project first and might give it a shot afterwards.

https://github.com/vladshcherbin/rollup-plugin-copy/blob/master/src/index.js#L114

@silvioprog
Copy link

This feature will be really very welcome.

a982246809 added a commit to a982246809/vite-plugin-static-copy that referenced this issue Apr 19, 2022
sapphi-red added a commit that referenced this issue Apr 21, 2022
* Feat: transform support #4
* Chore : Simplify the code
* Chore: fix package-lock.json
* Refactor: FileMap/TransformFunc type
* Refactor: check dir before copy
* Update: support E-Tag for transformed content
* Fix: improve error output
* Refactor: build transform
* Chore: format test
* Chore: restore removed comment
* Chore: update transform option docs
* Chore: improve debug output
* Chore: fix README

Co-authored-by: sapphi-red <[email protected]>
@troy351
Copy link
Author

troy351 commented Apr 22, 2022

Hey @sapphi-red , transform should support folders and every file inside the folder (maybe skip binary files) should be copied with this transform. At least that's how CopyWebpackPlugin works

@sapphi-red sapphi-red reopened this Apr 22, 2022
@irnnr
Copy link

irnnr commented Jun 1, 2022

edit: I need to finish a project first and might give it a shot afterwards.

I ended up using rollup-plugin-copy, works just fine

@FezVrasta
Copy link
Contributor

transform is supported, should we close this issue? @sapphi-red

@troy351
Copy link
Author

troy351 commented Aug 29, 2022

Folders are not supported right now

@FezVrasta
Copy link
Contributor

You can use a glob to grab all the folders files, that will work.

@troy351
Copy link
Author

troy351 commented Aug 29, 2022

any examples?

@FezVrasta
Copy link
Contributor

{
  src: 'folder/*',
  dest: 'build/folder',
  transform: content => content + 'b',
}

@troy351
Copy link
Author

troy351 commented Aug 30, 2022

└─folder1
    │  abc.txt
    │  test.png
    │  index.js
    │
    └─folder2
            code.js

I want to copy folder1 and transform all js code, glob not work.

Error: "transform" option only supports a file

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request PR welcome
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants