Skip to content

Commit 11dc4da

Browse files
committed
build: update npm package version after build
1 parent 6bccf68 commit 11dc4da

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

vite.config.mjs

+14
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
1+
import { readFile, writeFile } from 'node:fs/promises';
12
import { defineConfig, splitVendorChunkPlugin } from 'vite';
23
import react from '@vitejs/plugin-react';
34
import yaml from '@rollup/plugin-yaml';
45
import prerender from './tasks/prerender.mjs';
56

7+
const inputPkg = new URL('./package.json', import.meta.url);
8+
const outputPkg = new URL('./npm/package.json', import.meta.url);
9+
610
export default defineConfig({
711
clearScreen: false,
812
resolve: {
@@ -41,5 +45,15 @@ export default defineConfig({
4145
prerender({ file: 'index.html', source: 'src/index.jsx' }),
4246
prerender({ file: 'password-reset.html', source: 'src/password-reset/index.jsx' }),
4347
prerender({ file: 'privacy.html', source: 'src/markdown.jsx', props: { path: 'static/privacy.md' } }),
48+
{
49+
name: 'u-wave-write-package-version',
50+
apply: 'build',
51+
async closeBundle() {
52+
const { version } = JSON.parse(await readFile(inputPkg, 'utf8'));
53+
const pkg = JSON.parse(await readFile(outputPkg, 'utf8'));
54+
pkg.version = version;
55+
await writeFile(outputPkg, `${JSON.stringify(pkg, null, 2)}\n`);
56+
},
57+
},
4458
],
4559
});

0 commit comments

Comments
 (0)