Skip to content

Commit

Permalink
feat: include vite configs
Browse files Browse the repository at this point in the history
  • Loading branch information
stephenlago99 committed Jan 7, 2025
1 parent bafbadf commit f75e03d
Show file tree
Hide file tree
Showing 2 changed files with 103 additions and 0 deletions.
2 changes: 2 additions & 0 deletions vite-env.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/// <reference types="vite/client" />
/// <reference types="vite-plugin-svgr/client" />
101 changes: 101 additions & 0 deletions vite.config.ts
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

View workflow job for this annotation

GitHub Actions / Run linters

There should be at least one empty line between import groups

Check failure on line 1 in vite.config.ts

View workflow job for this annotation

GitHub Actions / Run linters

There should be at least one empty line between import groups

Check failure on line 1 in vite.config.ts

View workflow job for this annotation

GitHub Actions / Run linters

There should be at least one empty line between import groups
import { resolve } from 'node:path'

Check failure on line 2 in vite.config.ts

View workflow job for this annotation

GitHub Actions / Run linters

There should be at least one empty line between import groups

Check failure on line 2 in vite.config.ts

View workflow job for this annotation

GitHub Actions / Run linters

`node:path` import should occur before import of `@vitejs/plugin-react-swc`

Check failure on line 2 in vite.config.ts

View workflow job for this annotation

GitHub Actions / Run linters

There should be at least one empty line between import groups

Check failure on line 2 in vite.config.ts

View workflow job for this annotation

GitHub Actions / Run linters

`node:path` import should occur before import of `@vitejs/plugin-react-swc`

Check failure on line 2 in vite.config.ts

View workflow job for this annotation

GitHub Actions / Run linters

There should be at least one empty line between import groups

Check failure on line 2 in vite.config.ts

View workflow job for this annotation

GitHub Actions / Run linters

`node:path` import should occur before import of `@vitejs/plugin-react-swc`
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',
},
},
},
}
})

0 comments on commit f75e03d

Please sign in to comment.