From 6a015bade6774943d68fd1495954866c17611ea4 Mon Sep 17 00:00:00 2001 From: Neil Arya Date: Sat, 14 Oct 2023 15:55:48 +0530 Subject: [PATCH] Automatic version update from package file --- src/pages/home/index.tsx | 3 +-- src/version.ts | 1 + vite.config.js | 4 ++++ 3 files changed, 6 insertions(+), 2 deletions(-) create mode 100644 src/version.ts diff --git a/src/pages/home/index.tsx b/src/pages/home/index.tsx index 3f2a28d3..44cf6045 100644 --- a/src/pages/home/index.tsx +++ b/src/pages/home/index.tsx @@ -7,8 +7,7 @@ import { Link } from 'react-router-dom' import groups from './groups' import showcases from './showcases' import s from './styles.module.scss' - -const version = 'v1.3.0' +import version from '../../version' export default class Main extends React.Component { state = { diff --git a/src/version.ts b/src/version.ts new file mode 100644 index 00000000..ebf0e3bd --- /dev/null +++ b/src/version.ts @@ -0,0 +1 @@ +export default '1.4.0' \ No newline at end of file diff --git a/vite.config.js b/vite.config.js index 01b61275..4e1d7ae0 100644 --- a/vite.config.js +++ b/vite.config.js @@ -2,6 +2,10 @@ import { defineConfig } from 'vite' import react from '@vitejs/plugin-react-swc' import eslint from 'vite-plugin-eslint' import autoprefixer from 'autoprefixer' +import packageJSON from './package.json' +import fs from 'fs' + +fs.writeFileSync('src/version.ts', `export default '${packageJSON.version}'`) export default defineConfig({ plugins: [react(), eslint()],