Files
collection-portal/vite.config.ts
Podili Varshitha a5132d7ea1 NTP-37553| extension deprecation for ameyo| varshitha (#1386)
* NTP-37553|hrc testing| varshitha

* NTP-47834|creating bundle and assets folder|varshitha

* NTP-47834|creating bundle and assets folder|varshitha

* NTP-00000| action fix | varshitha

* NTP-00000| action fix | varshitha

* NTP-00000| action fix | varshitha

* NTP-50190 | removed hardcode checks | varshitha

* NTP-28813| call connected event data| varshitha

* NTP-28813| call connected event data| varshitha
2025-03-27 17:57:22 +05:30

141 lines
5.0 KiB
TypeScript

import { defineConfig, loadEnv, splitVendorChunkPlugin } from 'vite';
import react from '@vitejs/plugin-react';
import { visualizer } from 'rollup-plugin-visualizer';
import tsconfigPaths from 'vite-tsconfig-paths';
import { ViteMinifyPlugin } from 'vite-plugin-minify';
import mkcert from 'vite-plugin-mkcert';
import { createHtmlPlugin } from 'vite-plugin-html';
import { resolve } from 'path';
import cybertronSourceMapPlugin from '@navi/cybertron-vite-sourcemap-uploader';
import git from 'git-rev-sync';
export default async ({ mode }) => {
const { chunkSplitPlugin } = await import('vite-plugin-chunk-split');
// Load app-level env vars to node-level env vars.
process.env = { ...process.env, ...loadEnv(mode, process.cwd()) };
const version = git.short();
process.env.RELEASE_VERSION = version;
return defineConfig({
base: process?.env?.ASSET_PREFIX ? process?.env?.ASSET_PREFIX + 'new/' : '/',
define: {
'process.env.RELEASE_VERSION':
process.env.NODE_ENV == 'development' ? JSON.stringify(version) : version
},
build: {
minify: 'terser',
sourcemap: process.env.SKIP_SOURCEMAPS != 'true',
commonjsOptions: {
include: /node_modules/,
transformMixedEsModules: true
}
},
plugins: [
cybertronSourceMapPlugin({
key: 'navi',
apiBaseUrl:
process.env.ENV !== 'prod'
? 'https://cybetron.np.navi-ppl.in'
: 'https://cybertron.prod.navi-ppl.in',
runInDevelopment: false,
removeSourcemaps: true,
serviceName: process.env.APM_APP_NAME,
version: version
}),
tsconfigPaths(),
react(),
visualizer({
brotliSize: true,
gzipSize: true,
filename: 'stats/bundle-visualizer.html'
}),
ViteMinifyPlugin(),
mkcert({
hosts: ['thor-longhorn-portal.np.navi-ppl.in']
}),
createHtmlPlugin({
inject: {
data: {
CONFIGURATION_FILE:
mode === 'development' ? '/configuration.js' : `<CONFIGURATION_FILE>`
}
}
}),
chunkSplitPlugin({
strategy: 'single-vendor',
customSplitting: {
// `react` and `react-dom` will be bundled together in the `react-vendor` chunk (with their dependencies, such as object-assign)
'react-lottie': [/\/node_modules\/react-lottie\//],
// 'ag-grid': [/\/node_modules\/ag-grid-community\//, /\/node_modules\/ag-grid-react\//],
'wavesurfer.js': [/\/node_modules\/wavesurfer.js\//],
//'draft-js': [/\/node_modules\/draft-js\//, /\/node_modules\/@draft-js-plugins\/emoji\//],
'high-charts': [
/\/node_modules\/highcharts\//,
/\/node_modules\/highcharts-react\//,
/\/node_modules\/highcharts-react-official\//
],
'full-calendar': [
/\/node_modules\/@fullcalendar\/core\//,
/\/node_modules\/@fullcalendar\/daygrid\//,
/\/node_modules\/@fullcalendar\/interaction\//,
/\/node_modules\/@fullcalendar\/list\//,
/\/node_modules\/@fullcalendar\/react\//,
/\/node_modules\/@fullcalendar\/resource-timeline\//
],
assets: [/\/src\/assets\//],
firebase: [/\/node_modules\/firebase\//],
rechart: [/\/node_modules\/recharts\//],
crypto: [/\/node_modules\/crypto-js\//],
react: [
/\/node_modules\/react\//,
/\/node_modules\/react-dom\//,
/\/node_modules\/redux-persist\//,
/\/node_modules\/@reduxjs\/toolkit\//
]
}
})
],
esbuild: {
drop: process.env.NODE_ENV == 'development' ? [] : ['console']
},
server: {
https: true,
port: 3000,
proxy: {
'/api': {
target: 'https://qa-longhorn-server.np.navi-ppl.in',
changeOrigin: true,
rewrite: path => path.replace(/^\/api/, '')
},
'/cybertron-logs': {
target: 'https://qa-crm-ops-portal.np.navi-ppl.in/otlp/v1/logs',
changeOrigin: true,
rewrite: path => path.replace(/^\/cybertron-logs/, '')
},
'/ameyoHrc': {
target: 'https://app8.ameyoemerge.in:7443',
changeOrigin: true,
rewrite: path => path.replace(/^\/ameyoHrc/, '')
},
'/ameyoTele': {
target: 'https://naviapp1.ameyo.net:8443',
changeOrigin: true,
rewrite: path => path.replace(/^\/ameyoTele/, '')
}
}
},
resolve: {
alias: {
'@cp/src': resolve(__dirname, './src'),
'@cp/assets': resolve(__dirname, './src/assets'),
'@cp/components': resolve(__dirname, './src/components'),
'@cp/constants': resolve(__dirname, './src/constants'),
'@cp/hooks': resolve(__dirname, './src/hooks'),
'@cp/reducers': resolve(__dirname, './src/reducers'),
'@cp/pages': resolve(__dirname, './src/pages'),
'@cp/utils': resolve(__dirname, './src/utils')
}
}
});
};
// https://vitejs.dev/config//