增加自动构建版本和日期

dev/timezone
Jimmy Liow 1 year ago
parent ba70e3e17a
commit e005d6ac69

@ -7,6 +7,13 @@
2. 运行开发环境npm run dev 或者 start.bat
3. 打包代码npm run build 或者 build.bat
## 更新版本
v1.0.0 -> v1.0.1
npm version patch
v1.0.0 -> v1.1.0
npm version minor
## 相关文档

@ -9,6 +9,6 @@
<body>
<div id="root"></div>
<script type="module" src="/src/main.jsx"></script>
<p style="display: none;">BUILD_DATE: %BUILD_DATE%</p>
<p style="display: none;">VERSION: %BUILD_VERSION%</p>
</body>
</html>

@ -1,11 +1,12 @@
{
"name": "global-sales",
"private": true,
"version": "1.1.0",
"version": "1.0.4",
"type": "module",
"scripts": {
"dev": "vite",
"build": "vite build",
"publish": "npm version patch && npm run build",
"lint": "eslint . --ext js,jsx --report-unused-disable-directives --max-warnings 0",
"preview": "vite preview"
},

@ -2,12 +2,13 @@ import { defineConfig } from 'vite';
import react from '@vitejs/plugin-react';
import WindiCSS from 'vite-plugin-windicss';
import { VitePWA } from 'vite-plugin-pwa';
import packageJson from './package.json';
const buildDatePlugin = () => {
return {
transformIndexHtml(html) {
const dataString = new Date().toISOString();
return html.replace(/%BUILD_DATE%/, `${dataString}`);
return html.replace(/%BUILD_VERSION%/, `${packageJson.version}(${dataString})`);
},
};
};

Loading…
Cancel
Save