vue3+vite+多环境发面到二级目录配置
//vite.config.js import {defineConfig, loadEnv} from 'vite' import vue from '@vitejs/plugin-vue' // https://vite.dev/config/ export default defineConfig(({mode}) => { const env = loadEnv(mode, process.cwd(), ''); let baseDir = env.VITE_BASE_PATH; console.log('mode:' + mode + ', baseDir:' + baseDir); return { base: baseDir, plugins: [vue()], server: { host: '0.0.0.0' }, } }); //....
vue/react/node/vite/npm/yarn build自动更新版本号
//根目录 创建 version.js //安装 dayjs 或者 momentjs //修改package.json中build script为: node version.js & vite build //version.js如下: import fs from "fs"; import dayjs from "dayjs"; const getPackageJson = () => { let data = fs.readFileSync('./package.json') //fs读取文件 return JSON.parse(data) //转换为json对象 } let packageData = getPackageJson() packageData.version = dayjs().format('YYYYMMDDHHmm'); fs.writeFile( './package.j...