rollup-plugin-copy with dev server support.
Installations
npm install @brunoimbrizi/vite-plugin-static-copy
Developer Guide
Typescript
Yes
Module System
ESM
Min. Node Version
^14.18.0 || >=16.0.0
Node Version
18.12.1
NPM Version
9.2.0
Score
62.2
Supply Chain
83.3
Quality
74.4
Maintenance
100
Vulnerability
98.9
License
Releases
vite-plugin-static-copy@2.2.0
Published on 27 Nov 2024
vite-plugin-static-copy@2.1.0
Published on 08 Nov 2024
vite-plugin-static-copy@2.0.0
Published on 09 Oct 2024
vite-plugin-static-copy@1.0.6
Published on 02 Jul 2024
vite-plugin-static-copy@1.0.5
Published on 19 May 2024
vite-plugin-static-copy@1.0.4
Published on 01 May 2024
Contributors
Unable to fetch Contributors
Languages
TypeScript (97.69%)
JavaScript (2.31%)
Developer
sapphi-red
Download Statistics
Total Downloads
1,066
Last Day
1
Last Week
2
Last Month
27
Last Year
713
GitHub Statistics
311 Stars
213 Commits
32 Forks
2 Watching
1 Branches
17 Contributors
Bundle Size
152.51 kB
Minified
47.29 kB
Minified + Gzipped
Package Meta Information
Latest Version
0.15.0
Package Id
@brunoimbrizi/vite-plugin-static-copy@0.15.0
Unpacked Size
71.64 kB
Size
15.45 kB
File Count
6
NPM Version
9.2.0
Node Version
18.12.1
Publised On
25 May 2023
Total Downloads
Cumulative downloads
Total Downloads
1,066
Last day
-80%
1
Compared to previous day
Last week
-75%
2
Compared to previous week
Last month
125%
27
Compared to previous month
Last year
102%
713
Compared to previous year
Daily Downloads
Weekly Downloads
Monthly Downloads
Yearly Downloads
Dependencies
4
Peer Dependencies
1
vite-plugin-static-copy
rollup-plugin-copy
for Vite with dev server support.
Note Before you use this plugin, consider using public directory or
import
in JavaScript. In most cases, these will work.
Install
1npm i -D vite-plugin-static-copy # yarn add -D vite-plugin-static-copy
Usage
Add viteStaticCopy
plugin to vite.config.js
/ vite.config.ts
.
1// vite.config.js / vite.config.ts 2import { viteStaticCopy } from 'vite-plugin-static-copy' 3 4export default { 5 plugins: [ 6 viteStaticCopy({ 7 targets: [ 8 { 9 src: 'bin/example.wasm', 10 dest: 'wasm-files' 11 } 12 ] 13 }) 14 ] 15}
For example, if you use the config above, you will be able to fetch bin/example.wasm
with fetch('/wasm-files/example.wasm')
.
So the file will be copied to dist/wasm-files/example.wasm
.
Warning
If you are using Windows, make sure to use
normalizePath
after doingpath.resolve
or else.\
is a escape charactor infast-glob
and you should use/
.1import { normalizePath } from 'vite' 2import path from 'node:path' 3 4normalizePath(path.resolve(__dirname, './foo')) // C:/project/foo 5 6// instead of 7path.resolve(__dirname, './foo') // C:\project\foo
See
fast-glob
documentation about this for more details.
Options
See options.ts.
Differences with rollup-plugin-copy
- Faster dev server start-up than using
rollup-plugin-copy
onbuildStart
hook.- Files are not copied and served directly from the server during dev to reduce start-up time.
dest
is relative tobuild.outDir
.- If you are going to copy files outside
build.outDir
, you could userollup-plugin-copy
instead. Because that does not require dev server support.
- If you are going to copy files outside
fast-glob
is used instead ofglobby
.- Because
fast-glob
is used insidevite
.
- Because
transform
could returnnull
as a way to tell the plugin not to copy the file, this is similar to the CopyWebpackPlugin#filter option, but it expectstransform
to return the original content in case you want it to be copied.transform
can optionally be an object, with ahandler
property (with the same signature of therollup-plugin-copy
transform option) and anencoding
property (BufferEncoding | 'buffer'
) that will be used to read the file content so that thehandler
's content argument will reflect the correct encoding (could be Buffer);
No vulnerabilities found.
No security vulnerabilities found.