temp
This commit is contained in:
65
vite.config.mjs
Normal file
65
vite.config.mjs
Normal file
@@ -0,0 +1,65 @@
|
||||
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 basicSsl from '@vitejs/plugin-basic-ssl';
|
||||
import dotenv from 'dotenv';
|
||||
dotenv.config({ path: '.env.development' });
|
||||
const version = pkgs.version || '0.0.1';
|
||||
const isDev = process.env.NODE_ENV === 'development';
|
||||
const basename = isDev ? '/' : pkgs?.basename || '/';
|
||||
const plugins = [react(), tailwindcss()];
|
||||
const isCNB = process.env.CNB === 'true';
|
||||
if (isDev && !isCNB) {
|
||||
// plugins.push(basicSsl());
|
||||
}
|
||||
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/': {
|
||||
target: `${target}`,
|
||||
secure: false,
|
||||
},
|
||||
'/user/login/': {
|
||||
target: `${target}`,
|
||||
secure: false,
|
||||
},
|
||||
'/api': apiProxy,
|
||||
'/client': apiProxy,
|
||||
};
|
||||
/**
|
||||
* @see https://vitejs.dev/config/
|
||||
*/
|
||||
export default defineConfig(() => {
|
||||
return {
|
||||
plugins,
|
||||
resolve: {
|
||||
alias: {
|
||||
'@': path.resolve(__dirname, './src'),
|
||||
},
|
||||
},
|
||||
base: basename,
|
||||
envPrefix: 'KEVISUAL_',
|
||||
define: {
|
||||
DEV_SERVER: JSON.stringify(process.env.NODE_ENV === 'development'),
|
||||
APP_VERSION: JSON.stringify(version),
|
||||
BASE_NAME: JSON.stringify(basename),
|
||||
'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV),
|
||||
},
|
||||
build: {
|
||||
target: 'modules',
|
||||
// lib: {
|
||||
// entry: './src/libs.ts',
|
||||
// formats: ['es'],
|
||||
// fileName: (format) => `render.js`,
|
||||
// },
|
||||
},
|
||||
server: {
|
||||
port: 7008,
|
||||
host: '0.0.0.0',
|
||||
allowedHosts: true,
|
||||
proxy,
|
||||
},
|
||||
};
|
||||
});
|
||||
Reference in New Issue
Block a user