mirror of
https://github.com/logto-io/logto.git
synced 2025-01-27 21:39:16 -05:00
55 lines
1.8 KiB
TypeScript
55 lines
1.8 KiB
TypeScript
import mdx from '@mdx-js/rollup';
|
|
import react from '@vitejs/plugin-react';
|
|
import dotenv from 'dotenv';
|
|
import { findUp } from 'find-up';
|
|
import rehypeMdxCodeProps from 'rehype-mdx-code-props';
|
|
import remarkGfm from 'remark-gfm';
|
|
import { defineConfig, mergeConfig, type UserConfig } from 'vite';
|
|
import viteCompression from 'vite-plugin-compression';
|
|
import svgr from 'vite-plugin-svgr';
|
|
|
|
import { defaultConfig } from '../../vite.shared.config';
|
|
|
|
// We need to explicitly import the `.env` file and use `define` later because we do not have a
|
|
// prefix for our environment variables which it is required in Vite.
|
|
// @see {@link https://vitejs.dev/config/shared-options.html#envprefix}
|
|
dotenv.config({ path: await findUp('.env', {}) });
|
|
|
|
const buildConfig = (mode: string): UserConfig => ({
|
|
base: `/${process.env.CONSOLE_PUBLIC_URL ?? 'console'}`,
|
|
envDir: '../../',
|
|
server: {
|
|
port: 5002,
|
|
hmr: {
|
|
port: 6002,
|
|
},
|
|
},
|
|
css: {
|
|
modules: {
|
|
generateScopedName: '__[hash:base64:5]__[local]',
|
|
},
|
|
},
|
|
plugins: [
|
|
{
|
|
enforce: 'pre',
|
|
...mdx({
|
|
providerImportSource: '@mdx-js/react',
|
|
remarkPlugins: [remarkGfm],
|
|
rehypePlugins: [[rehypeMdxCodeProps, { tagName: 'code' }]],
|
|
}),
|
|
},
|
|
react(),
|
|
svgr(),
|
|
viteCompression({ disable: mode === 'development' }),
|
|
],
|
|
define: {
|
|
'import.meta.env.IS_CLOUD': JSON.stringify(process.env.IS_CLOUD),
|
|
'import.meta.env.ADMIN_ENDPOINT': JSON.stringify(process.env.ADMIN_ENDPOINT),
|
|
'import.meta.env.DEV_FEATURES_ENABLED': JSON.stringify(process.env.DEV_FEATURES_ENABLED),
|
|
'import.meta.env.INTEGRATION_TEST': JSON.stringify(process.env.INTEGRATION_TEST),
|
|
// `@withtyped/client` needs this to be defined. We can optimize this later.
|
|
'process.env': {},
|
|
},
|
|
});
|
|
|
|
export default defineConfig(({ mode }) => mergeConfig(defaultConfig, buildConfig(mode)));
|