fuware-fe/vite.config.js
Sam Liu bf275844d2
All checks were successful
Gitea Actions Demo / check (push) Successful in 25s
update for stg
2024-09-30 18:00:00 +07:00

88 lines
2.0 KiB
JavaScript

import react from '@vitejs/plugin-react'
import path, { dirname } from 'path'
import { fileURLToPath } from 'url'
import { defineConfig, loadEnv } from 'vite'
const _dirname = dirname(fileURLToPath(import.meta.url))
// https://vitejs.dev/config/
export default defineConfig(({ mode }) => {
// eslint-disable-next-line no-undef
const env = loadEnv(mode, process.cwd(), '')
const config_sv = {
resolve: {
alias: {
'@': path.resolve(_dirname, './src'),
'@lang': path.resolve(_dirname, './src/lang'),
'@api': path.resolve(_dirname, './src/api'),
'@hooks': path.resolve(_dirname, './src/hooks'),
'@pages': path.resolve(_dirname, './src/pages'),
'@components': path.resolve(_dirname, './src/components'),
'@routes': path.resolve(_dirname, './src/routes'),
'@utils': path.resolve(_dirname, './src/utils'),
'@assets': path.resolve(_dirname, './src/assets'),
'@context': path.resolve(_dirname, './src/context'),
},
},
plugins: [react()],
css: {
preprocessorOptions: {
scss: {
additionalData: '@import "./src/_mantine";',
},
},
},
}
// production
if (env.NODE_ENV === 'production') {
return {
...config_sv,
server: {
https: false,
host: false,
port: 5001,
strictPort: true,
watch: {
usePolling: true,
},
},
}
}
if (env.NODE_ENV === 'stg') {
return {
...config_sv,
server: {
https: false,
host: false,
port: 5001,
strictPort: true,
watch: {
usePolling: true,
},
proxy: {
'/api': 'https://stg-be.samliu.io.vn',
},
},
}
}
return {
...config_sv,
server: {
https: false,
host: true,
port: 5001,
strictPort: true,
watch: {
usePolling: true,
},
proxy: {
'/api': 'http://localhost:9000',
},
},
}
})