vite-plugin-static-copy icon indicating copy to clipboard operation
vite-plugin-static-copy copied to clipboard

`transform` support

Open troy351 opened this issue 3 years ago • 10 comments

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

troy351 avatar Feb 26 '22 09:02 troy351

+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

irnnr avatar Apr 01 '22 04:04 irnnr

This feature will be really very welcome.

silvioprog avatar Apr 12 '22 00:04 silvioprog

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

troy351 avatar Apr 22 '22 06:04 troy351

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

irnnr avatar Jun 01 '22 19:06 irnnr

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

FezVrasta avatar Aug 29 '22 12:08 FezVrasta

Folders are not supported right now

troy351 avatar Aug 29 '22 13:08 troy351

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

FezVrasta avatar Aug 29 '22 13:08 FezVrasta

any examples?

troy351 avatar Aug 29 '22 14:08 troy351

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

FezVrasta avatar Aug 29 '22 14:08 FezVrasta

└─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

troy351 avatar Aug 30 '22 02:08 troy351