{"id":13417321,"url":"https://github.com/sapphi-red/vite-plugin-static-copy","last_synced_at":"2026-04-01T23:03:51.724Z","repository":{"id":38106461,"uuid":"435767414","full_name":"sapphi-red/vite-plugin-static-copy","owner":"sapphi-red","description":"rollup-plugin-copy with dev server support.","archived":false,"fork":false,"pushed_at":"2026-03-22T07:58:23.000Z","size":862,"stargazers_count":412,"open_issues_count":5,"forks_count":39,"subscribers_count":2,"default_branch":"main","last_synced_at":"2026-03-22T22:31:14.375Z","etag":null,"topics":["vite","vite-plugin"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/sapphi-red.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null},"funding":{"github":"sapphi-red"}},"created_at":"2021-12-07T06:23:42.000Z","updated_at":"2026-03-22T07:58:04.000Z","dependencies_parsed_at":"2024-01-28T12:28:46.412Z","dependency_job_id":"cce4b9a7-5cb2-4fc5-b3ff-6b7124862afb","html_url":"https://github.com/sapphi-red/vite-plugin-static-copy","commit_stats":{"total_commits":130,"total_committers":8,"mean_commits":16.25,"dds":0.06153846153846154,"last_synced_commit":"c86bb2bb27c69d547d3996fda3fe222b904970dc"},"previous_names":[],"tags_count":54,"template":false,"template_full_name":null,"purl":"pkg:github/sapphi-red/vite-plugin-static-copy","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sapphi-red%2Fvite-plugin-static-copy","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sapphi-red%2Fvite-plugin-static-copy/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sapphi-red%2Fvite-plugin-static-copy/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sapphi-red%2Fvite-plugin-static-copy/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sapphi-red","download_url":"https://codeload.github.com/sapphi-red/vite-plugin-static-copy/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sapphi-red%2Fvite-plugin-static-copy/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31292789,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-01T21:15:39.731Z","status":"ssl_error","status_checked_at":"2026-04-01T21:15:34.046Z","response_time":53,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["vite","vite-plugin"],"created_at":"2024-07-30T22:00:35.327Z","updated_at":"2026-04-01T23:03:51.658Z","avatar_url":"https://github.com/sapphi-red.png","language":"TypeScript","funding_links":["https://github.com/sponsors/sapphi-red"],"categories":["Plugins","others","TypeScript"],"sub_categories":["Framework-agnostic Plugins"],"readme":"# vite-plugin-static-copy\n\n[![npm version](https://badge.fury.io/js/vite-plugin-static-copy.svg)](https://badge.fury.io/js/vite-plugin-static-copy) ![CI](https://github.com/sapphi-red/vite-plugin-static-copy/workflows/CI/badge.svg) [![MIT License](http://img.shields.io/badge/license-MIT-blue.svg?style=flat)](LICENSE)\n\n[`rollup-plugin-copy`](https://www.npmjs.com/package/rollup-plugin-copy) for Vite with dev server support.\n\n\u003e [!NOTE]\n\u003e Before you use this plugin, consider using [public directory](https://vitejs.dev/guide/assets.html#the-public-directory) or [`import` in JavaScript](https://vitejs.dev/guide/features.html#static-assets).\n\u003e In most cases, these will work.\n\n## Install\n\n```shell\nnpm i -D vite-plugin-static-copy # yarn add -D vite-plugin-static-copy\n```\n\n## Usage\n\nAdd `viteStaticCopy` plugin to `vite.config.js` / `vite.config.ts`.\n\n```js\n// vite.config.js / vite.config.ts\nimport { viteStaticCopy } from 'vite-plugin-static-copy'\n\nexport default {\n  plugins: [\n    viteStaticCopy({\n      targets: [\n        {\n          src: 'bin/example.wasm',\n          dest: 'wasm-files',\n          rename: { stripBase: 1 }, // strips `bin/`\n        },\n      ],\n    }),\n  ],\n}\n```\n\nFor example, if you use the config above, you will be able to fetch `bin/example.wasm` with `fetch('/wasm-files/example.wasm')`.\nSo the file will be copied to `dist/wasm-files/example.wasm`.\n\n\u003e [!WARNING]\n\u003e\n\u003e If you are using Windows, make sure to use `normalizePath` after doing `path.resolve` or else.\n\u003e `\\` is a escape charactor in `tinyglobby` and you should use `/`.\n\u003e\n\u003e ```js\n\u003e import { normalizePath } from 'vite'\n\u003e import path from 'node:path'\n\u003e\n\u003e normalizePath(path.resolve(__dirname, './foo')) // C:/project/foo\n\u003e\n\u003e // instead of\n\u003e path.resolve(__dirname, './foo') // C:\\project\\foo\n\u003e ```\n\n### Options\n\nSee [options.ts](https://github.com/sapphi-red/vite-plugin-static-copy/blob/main/src/options.ts).\n\n### Debug\n\nYou can enable detailed logging by setting the `DEBUG` environment variable:\n\n```bash\nDEBUG=vite:plugin-static-copy npm run dev\n```\n\nWhen debug logging is enabled, the plugin will output which file is served from each URL.\n\n## Differences with `rollup-plugin-copy`\n\n- Faster dev server start-up than using `rollup-plugin-copy` on `buildStart` hook.\n  - Files are not copied and served directly from the server during dev to reduce start-up time.\n- `dest` is relative to [`build.outDir`](https://vitejs.dev/config/build-options.html#build-outdir).\n  - If you are going to copy files outside `build.outDir`, you could use `rollup-plugin-copy` instead. Because that does not require dev server support.\n- [`tinyglobby`](https://www.npmjs.com/package/tinyglobby) is used instead of [`globby`](https://www.npmjs.com/package/globby).\n  - Because `tinyglobby` is used inside `vite`.\n- `transform` could return `null` as a way to tell the plugin not to copy the file, this is similar to the [CopyWebpackPlugin#filter](https://webpack.js.org/plugins/copy-webpack-plugin/#filter) option, but it expects `transform` to return the original content in case you want it to be copied.\n- `transform` can optionally be an object, with a `handler` property (with the same signature of the `rollup-plugin-copy` transform option) and an `encoding` property (`BufferEncoding | 'buffer'`) that will be used to read the file content so that the `handler`'s content argument will reflect the correct encoding (could be Buffer);\n- Directory structure is always preserved in the output (similar to `flatten: false` in `rollup-plugin-copy`). Use `rename: { stripBase: true }` for flat copy.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsapphi-red%2Fvite-plugin-static-copy","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsapphi-red%2Fvite-plugin-static-copy","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsapphi-red%2Fvite-plugin-static-copy/lists"}