Skip to content

Instantly share code, notes, and snippets.

@raygesualdo
Created November 21, 2024 17:33
Show Gist options
  • Select an option

  • Save raygesualdo/9d2533b07f318eb7641921d06999204b to your computer and use it in GitHub Desktop.

Select an option

Save raygesualdo/9d2533b07f318eb7641921d06999204b to your computer and use it in GitHub Desktop.
Copy files after build with Rsbuild
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)
})
},
}
}
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