LibreChat/client/vite.config.ts

63 lines
1.4 KiB
TypeScript
Raw Normal View History

2023-04-03 21:31:59 +08:00
import { defineConfig } from 'vite';
import react from '@vitejs/plugin-react';
import path from 'path';
import type { Plugin } from "vite";
// https://vitejs.dev/config/
export default defineConfig({
server: {
2023-04-03 21:31:59 +08:00
host: 'localhost',
port: 3090,
strictPort: false,
proxy: {
2023-04-03 21:31:59 +08:00
'/api': {
target: 'http://localhost:3080',
changeOrigin: true
},
'/auth': {
target: 'http://localhost:3080',
changeOrigin: true
}
}
},
plugins: [react(), sourcemapExclude({ excludeNodeModules: true }),],
2023-04-03 21:31:59 +08:00
publicDir: './public',
build: {
sourcemap: true,
outDir: './dist',
rollupOptions: {
output: {
manualChunks: (id) => {
if (id.includes("node_modules")) {
return "vendor";
}
},
},
},
},
resolve: {
alias: {
2023-04-03 21:31:59 +08:00
'~': path.join(__dirname, 'src/')
}
}
});
interface SourcemapExclude {
excludeNodeModules?: boolean;
}
export function sourcemapExclude(opts?: SourcemapExclude): Plugin {
return {
name: "sourcemap-exclude",
transform(code: string, id: string) {
if (opts?.excludeNodeModules && id.includes("node_modules")) {
return {
code,
// https://github.com/rollup/rollup/blob/master/docs/plugin-development/index.md#source-code-transformations
map: { mappings: "" },
};
}
},
};
}