feat: 添加web项目基础配置和依赖
添加web项目基础结构,包括vite配置、ts配置、package.json和示例代码 添加pnpm工作区配置 更新.gitignore包含pnpm-store
This commit is contained in:
41
web/vite.config.ts
Normal file
41
web/vite.config.ts
Normal file
@@ -0,0 +1,41 @@
|
||||
import { defineConfig } from 'vite';
|
||||
import path from 'path';
|
||||
import pkgs from './package.json';
|
||||
import dotenv from 'dotenv';
|
||||
dotenv.config();
|
||||
const isDev = process.env.NODE_ENV === 'development';
|
||||
const plugins: any = [];
|
||||
|
||||
let target = process.env.VITE_API_URL || 'http://localhost:51515';
|
||||
const apiProxy = { target: target, changeOrigin: true, ws: true, rewriteWsOrigin: true, secure: false, cookieDomainRewrite: 'localhost' };
|
||||
let proxy = {
|
||||
'/root/': apiProxy,
|
||||
'/api': apiProxy,
|
||||
'/client': apiProxy,
|
||||
};
|
||||
const ENV_BASE_NAME = process.env.BASE_NAME;
|
||||
|
||||
const _basename = ENV_BASE_NAME || pkgs.basename;
|
||||
const basename = isDev ? undefined : `${_basename}`;
|
||||
/**
|
||||
* @see https://vitejs.dev/config/
|
||||
*/
|
||||
export default defineConfig({
|
||||
plugins,
|
||||
resolve: {
|
||||
alias: {
|
||||
'@': path.resolve(__dirname, './src'),
|
||||
},
|
||||
},
|
||||
base: basename,
|
||||
define: {
|
||||
BASE_NAME: JSON.stringify(basename),
|
||||
BUILD_TIME: JSON.stringify(new Date().toISOString()),
|
||||
},
|
||||
server: {
|
||||
port: 7008,
|
||||
host: '::',
|
||||
allowedHosts: true,
|
||||
proxy,
|
||||
},
|
||||
});
|
||||
Reference in New Issue
Block a user