Files
kv-code/vite.config.ts
abearxiong 5f6536e758 feat: Initialize simple-lit-vite project with Lit and Vite setup
- Add README.md for project description and CLI usage
- Create main application component with basic structure in app.tsx
- Implement CodeMirror editor base functionality in editor.base.ts
- Extend CodeMirror editor for JSON support in editor.json.ts
- Add support for multiple languages in editor.ts
- Create utility functions for editor manipulation in editor.utils.ts
- Implement tab key formatting and indentation in tab.ts
- Add Tailwind CSS integration in index.css
- Develop JSON editor web component in json.ts
- Create a template component for rendering in lib.ts
- Set up main entry point in main.ts
- Configure TypeScript settings in tsconfig.json
- Define custom element typings in typings.d.ts
- Configure Vite for library and application builds in vite.config.lib.ts and vite.config.ts
2025-12-18 03:35:17 +08:00

45 lines
1.2 KiB
TypeScript

import { defineConfig } from 'vite';
import react from '@vitejs/plugin-react';
import path from 'path';
import pkgs from './package.json';
import tailwindcss from '@tailwindcss/vite';
import dotenv from 'dotenv';
dotenv.config();
const isDev = process.env.NODE_ENV === 'development';
const plugins = [react(), tailwindcss()];
let target = process.env.VITE_API_URL || 'http://localhost:51015';
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(() => {
return {
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: '0.0.0.0',
proxy,
},
};
});