2023-12-10 18:22:43 +03:00
|
|
|
import react from '@vitejs/plugin-react-swc';
|
2024-01-10 19:42:11 +03:00
|
|
|
import { defineConfig, loadEnv } from 'vite';
|
|
|
|
import checker from 'vite-plugin-checker';
|
2023-12-10 18:22:43 +03:00
|
|
|
import svgr from 'vite-plugin-svgr';
|
2024-01-10 19:42:11 +03:00
|
|
|
import tsconfigPaths from 'vite-tsconfig-paths';
|
|
|
|
|
|
|
|
type Checkers = Parameters<typeof checker>[0];
|
2023-12-10 18:22:43 +03:00
|
|
|
|
|
|
|
// https://vitejs.dev/config/
|
2024-01-10 19:42:11 +03:00
|
|
|
export default defineConfig(({ command, mode }) => {
|
|
|
|
const env = loadEnv(mode, process.cwd(), '');
|
2023-12-10 18:22:43 +03:00
|
|
|
|
|
|
|
/*
|
|
|
|
Using explicit env variables, there is no need to expose all of them (security).
|
|
|
|
*/
|
2024-04-15 13:12:59 +03:00
|
|
|
const { REACT_APP_SERVER_BASE_URL, VITE_BUILD_SOURCEMAP } = env;
|
2024-01-10 19:42:11 +03:00
|
|
|
|
|
|
|
const isBuildCommand = command === 'build';
|
|
|
|
|
|
|
|
const checkers: Checkers = {
|
|
|
|
typescript: {
|
|
|
|
tsconfigPath: 'tsconfig.app.json',
|
|
|
|
},
|
2024-01-22 16:19:22 +03:00
|
|
|
overlay: false,
|
2024-01-10 19:42:11 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
if (!isBuildCommand) {
|
|
|
|
checkers['eslint'] = {
|
|
|
|
lintCommand:
|
|
|
|
'eslint . --report-unused-disable-directives --max-warnings 0 --config .eslintrc.cjs',
|
|
|
|
};
|
|
|
|
}
|
2023-12-10 18:22:43 +03:00
|
|
|
|
|
|
|
return {
|
2024-04-04 16:38:01 +03:00
|
|
|
root: __dirname,
|
|
|
|
cacheDir: '../../node_modules/.vite/packages/twenty-front',
|
|
|
|
|
2023-12-10 18:22:43 +03:00
|
|
|
server: {
|
|
|
|
port: 3001,
|
2024-04-04 16:38:01 +03:00
|
|
|
host: 'localhost',
|
|
|
|
},
|
|
|
|
|
|
|
|
plugins: [
|
|
|
|
react({ jsxImportSource: '@emotion/react' }),
|
|
|
|
tsconfigPaths({
|
2024-04-12 16:30:48 +03:00
|
|
|
projects: ['tsconfig.json', '../twenty-ui/tsconfig.json'],
|
2024-04-04 16:38:01 +03:00
|
|
|
}),
|
|
|
|
svgr(),
|
|
|
|
checker(checkers),
|
|
|
|
],
|
|
|
|
|
|
|
|
build: {
|
|
|
|
outDir: 'build',
|
2024-04-15 13:12:59 +03:00
|
|
|
sourcemap: VITE_BUILD_SOURCEMAP === 'true',
|
2023-12-10 18:22:43 +03:00
|
|
|
},
|
2024-04-04 16:38:01 +03:00
|
|
|
|
|
|
|
envPrefix: 'REACT_APP_',
|
|
|
|
|
2023-12-10 18:22:43 +03:00
|
|
|
define: {
|
2024-01-10 19:42:11 +03:00
|
|
|
'process.env': {
|
2023-12-10 18:22:43 +03:00
|
|
|
REACT_APP_SERVER_BASE_URL,
|
2024-01-10 19:42:11 +03:00
|
|
|
},
|
|
|
|
},
|
|
|
|
};
|
2023-12-10 18:22:43 +03:00
|
|
|
});
|