Created
November 21, 2024 17:33
-
-
Save raygesualdo/9d2533b07f318eb7641921d06999204b to your computer and use it in GitHub Desktop.
Copy files after build with Rsbuild
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import type { RsbuildPlugin } from '@rsbuild/core' | |
| export function pluginCopyManifest({ | |
| gitSha, | |
| }: { | |
| gitSha: string | |
| }): RsbuildPlugin { | |
| return { | |
| name: 'my-project:copy-manifest', | |
| async setup(api) { | |
| const { cpSync } = await import('node:fs') | |
| api.onAfterBuild(({ environments }) => { | |
| const from = `${environments.web.distPath}/manifest.json` | |
| const to = `${environments.web.distPath}/manifest.${gitSha}.json` | |
| cpSync(from, to) | |
| }) | |
| }, | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { pluginCopyManifest } from './plugins.ts' | |
| export default defineConfig({ | |
| // ... | |
| plugins: [ | |
| pluginCopyManifest({ gitSha: 'abcd123' }), | |
| ], | |
| // ... | |
| }) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment