{"id":20343196,"url":"https://github.com/MrQinYQ/vite-plugin-static-filehash","last_synced_at":"2025-05-08T03:33:25.849Z","repository":{"id":255350193,"uuid":"848157333","full_name":"MrQinYQ/vite-plugin-static-filehash","owner":"MrQinYQ","description":"A Vite plugin that tries to keep the hash of a single file unchanged","archived":false,"fork":false,"pushed_at":"2024-11-01T05:38:24.000Z","size":52,"stargazers_count":1,"open_issues_count":1,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-11-01T05:39:45.426Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/MrQinYQ.png","metadata":{"files":{"readme":"README.md","changelog":null,"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}},"created_at":"2024-08-27T08:37:33.000Z","updated_at":"2024-11-01T05:38:27.000Z","dependencies_parsed_at":"2024-08-29T13:11:59.991Z","dependency_job_id":null,"html_url":"https://github.com/MrQinYQ/vite-plugin-static-filehash","commit_stats":null,"previous_names":["mrqinyq/vite-plugin-static-filehash"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MrQinYQ%2Fvite-plugin-static-filehash","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MrQinYQ%2Fvite-plugin-static-filehash/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MrQinYQ%2Fvite-plugin-static-filehash/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MrQinYQ%2Fvite-plugin-static-filehash/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/MrQinYQ","download_url":"https://codeload.github.com/MrQinYQ/vite-plugin-static-filehash/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":224698435,"owners_count":17354771,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":[],"created_at":"2024-11-14T22:00:56.722Z","updated_at":"2024-11-14T22:02:41.056Z","avatar_url":"https://github.com/MrQinYQ.png","language":"TypeScript","funding_links":[],"categories":["Plugins"],"sub_categories":["Framework-agnostic Plugins"],"readme":"## A Vite plugin that tries to keep the hash of a single file unchanged\r\n\r\nWhen we update our program, if we only change one file, such as modifying the About file, it will still affect the cache hit of the entry file. This is because the hash change of the file affects other files, causing the content of other files to change, and their hashes to change. The change of hash spreads like a virus, affecting all files that depend on it, including the entry file.\r\n\r\nSo the role of this plugin is that when you modify one file, it will never affect other files.\r\n\r\nBecause this solution relies on import map, in order to ensure normal operation, es-module-shims dependency will be introduced into the project.\r\n\r\n```typescript\r\nimport { \r\n  defineConfig, \r\n} from 'vite'\r\nimport react from '@vitejs/plugin-react-swc'\r\n\r\nimport staticFilehashPlugin from 'vite-plugin-static-filehash';\r\n\r\n// https://vitejs.dev/config/\r\nexport default defineConfig({\r\n  plugins: [\r\n    react(), \r\n    staticFilehashPlugin(),\r\n  ],\r\n})\r\n\r\n```\r\n\r\nOutput filehashs.js file separately.\r\n\r\n```typescript\r\ninterface PluginConfig {\r\n  emitFile?: boolean;\r\n}\r\n\r\n// staticFilehashPlugin({ emitFile: true })\r\n```\r\n\r\n\r\nThe effect of not using this plugin:\r\n\r\n\r\n![image](https://github.com/user-attachments/assets/6a1e110c-9cf9-4624-9857-13d46eeedc4b)\r\n\r\n![image](https://github.com/user-attachments/assets/529d9852-0940-4f26-8ee2-57e80c9b2dfd)\r\n\r\n![image](https://github.com/user-attachments/assets/027adaec-8ff0-4fac-a254-72409475c7e6)\r\n\r\nThe effect of using this plugin:\r\n\r\n\r\n![image](https://github.com/user-attachments/assets/f9581e43-2fcf-4c27-aa0b-ae72048f11d4)\r\n\r\n![image](https://github.com/user-attachments/assets/f224b714-7c99-47f6-a159-94d237c682fc)\r\n\r\n![image](https://github.com/user-attachments/assets/bd6418f2-8de3-4238-84b0-383a884f18c4)\r\n\r\n![image](https://github.com/user-attachments/assets/ab78feee-871e-4be1-a509-1ebca304740b)\r\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FMrQinYQ%2Fvite-plugin-static-filehash","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FMrQinYQ%2Fvite-plugin-static-filehash","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FMrQinYQ%2Fvite-plugin-static-filehash/lists"}