-
Notifications
You must be signed in to change notification settings - Fork 58
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
bafbadf
commit f75e03d
Showing
2 changed files
with
103 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
/// <reference types="vite/client" /> | ||
/// <reference types="vite-plugin-svgr/client" /> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
import react from '@vitejs/plugin-react-swc' | ||
Check failure on line 1 in vite.config.ts GitHub Actions / Run linters
Check failure on line 1 in vite.config.ts GitHub Actions / Run linters
|
||
import { resolve } from 'node:path' | ||
Check failure on line 2 in vite.config.ts GitHub Actions / Run linters
Check failure on line 2 in vite.config.ts GitHub Actions / Run linters
Check failure on line 2 in vite.config.ts GitHub Actions / Run linters
Check failure on line 2 in vite.config.ts GitHub Actions / Run linters
Check failure on line 2 in vite.config.ts GitHub Actions / Run linters
|
||
import { defineConfig, loadEnv } from 'vite' | ||
import { createHtmlPlugin } from 'vite-plugin-html' | ||
import svgr from 'vite-plugin-svgr' | ||
import topLevelAwait from 'vite-plugin-top-level-await' | ||
import wasm from 'vite-plugin-wasm' | ||
|
||
import { version } from './package.json' | ||
|
||
const icons: Record<string, string> = { | ||
development: '/favicon-local.svg', | ||
production: '/favicon-prod.svg', | ||
staging: '/favicon-staging.svg', | ||
} | ||
|
||
const titles: Record<string, string> = { | ||
development: 'Lago - Local', | ||
production: 'Lago', | ||
staging: 'Lago - Cloud', | ||
} | ||
|
||
export default defineConfig(({ mode }) => { | ||
const env = loadEnv(mode, process.cwd(), '') | ||
const port = env.PORT ? parseInt(env.PORT) : 8080 | ||
|
||
return { | ||
plugins: [ | ||
react({ | ||
plugins: [['@swc/plugin-styled-components', { displayName: true }]], | ||
}), | ||
|
||
wasm(), | ||
topLevelAwait(), | ||
|
||
svgr({ | ||
include: '**/*.svg', | ||
svgrOptions: { | ||
plugins: ['@svgr/plugin-svgo', '@svgr/plugin-jsx'], | ||
svgoConfig: { | ||
plugins: [ | ||
{ | ||
name: 'prefixIds', | ||
params: { | ||
prefixIds: false, | ||
prefixClassNames: false, | ||
}, | ||
}, | ||
], | ||
}, | ||
}, | ||
}), | ||
|
||
createHtmlPlugin({ | ||
inject: { | ||
data: { | ||
title: titles[env.APP_ENV] || titles.production, | ||
favicon: icons[env.APP_ENV] || icons.production, | ||
}, | ||
}, | ||
}), | ||
], | ||
define: { | ||
APP_ENV: JSON.stringify(env.APP_ENV), | ||
API_URL: JSON.stringify(env.API_URL), | ||
DOMAIN: JSON.stringify(env.LAGO_DOMAIN), | ||
APP_VERSION: JSON.stringify(version), | ||
LAGO_OAUTH_PROXY_URL: JSON.stringify(env.LAGO_OAUTH_PROXY_URL), | ||
LAGO_DISABLE_SIGNUP: JSON.stringify(env.LAGO_DISABLE_SIGNUP), | ||
NANGO_PUBLIC_KEY: JSON.stringify(env.NANGO_PUBLIC_KEY), | ||
SENTRY_DSN: JSON.stringify(env.SENTRY_DSN), | ||
}, | ||
resolve: { | ||
alias: { | ||
'~': resolve(__dirname, 'src'), | ||
lodash: 'lodash-es', | ||
'@mui/styled-engine': resolve(__dirname, 'node_modules/@mui/styled-engine-sc'), | ||
}, | ||
}, | ||
server: { | ||
port, | ||
host: true, | ||
strictPort: true, | ||
}, | ||
preview: { | ||
port, | ||
}, | ||
build: { | ||
outDir: 'dist', | ||
sourcemap: true, | ||
target: 'esnext', | ||
rollupOptions: { | ||
output: { | ||
chunkFileNames: '[name].[hash].js', | ||
entryFileNames: '[name].[hash].js', | ||
sourcemapFileNames: '[name].[hash].js.map', | ||
}, | ||
}, | ||
}, | ||
} | ||
}) |