add code chunking to vite.config.ts

This commit is contained in:
Amruth Pillai
2024-05-07 11:45:33 +02:00
parent e21430a421
commit e3785030e1
11 changed files with 616 additions and 707 deletions

View File

@ -3,6 +3,7 @@
import { nxViteTsPaths } from "@nx/vite/plugins/nx-tsconfig-paths.plugin";
import react from "@vitejs/plugin-react-swc";
import { defineConfig, searchForWorkspaceRoot } from "vite";
import { chunkSplitPlugin } from "vite-plugin-chunk-split";
export default defineConfig({
base: "/artboard/",
@ -20,7 +21,13 @@ export default defineConfig({
fs: { allow: [searchForWorkspaceRoot(process.cwd())] },
},
plugins: [react(), nxViteTsPaths()],
plugins: [
react(),
nxViteTsPaths(),
chunkSplitPlugin({
strategy: "unbundle",
}),
],
resolve: {
alias: {

View File

@ -24,9 +24,9 @@ if (import.meta.env.VITE_CLIENT_SENTRY_DSN) {
}),
Sentry.replayIntegration(),
],
tracesSampleRate: 0.5,
replaysOnErrorSampleRate: 0.5,
replaysSessionSampleRate: 0.25,
tracesSampleRate: 1,
replaysOnErrorSampleRate: 1,
replaysSessionSampleRate: 1,
});
}

View File

@ -4,6 +4,7 @@
declare const appVersion: string;
interface ImportMetaEnv {
SENTRY_AUTH_TOKEN: string | undefined;
VITE_CLIENT_SENTRY_DSN: string | undefined;
VITE_DISABLE_SIGNUPS: string | undefined;
}

View File

@ -1,9 +1,11 @@
/// <reference types='vitest' />
import { lingui } from "@lingui/vite-plugin";
import { nxViteTsPaths } from "@nx/vite/plugins/nx-tsconfig-paths.plugin";
import { sentryVitePlugin } from "@sentry/vite-plugin";
import react from "@vitejs/plugin-react";
import { defineConfig, searchForWorkspaceRoot } from "vite";
import { chunkSplitPlugin } from "vite-plugin-chunk-split";
export default defineConfig({
cacheDir: "../../node_modules/.vite/client",
@ -39,7 +41,11 @@ export default defineConfig({
}),
lingui(),
nxViteTsPaths(),
chunkSplitPlugin({
strategy: "unbundle",
}),
sentryVitePlugin({
disable: process.env.SENTRY_AUTH_TOKEN === undefined,
org: "reactive-resume",
project: "client",
}),

View File

@ -70,6 +70,12 @@ export class AuthService {
}
}
async setLastSignedIn(email: string) {
await this.userService.updateByEmail(email, {
secrets: { update: { lastSignedIn: new Date() } },
});
}
async setRefreshToken(email: string, token: string | null) {
await this.userService.updateByEmail(email, {
secrets: {
@ -129,6 +135,7 @@ export class AuthService {
}
await this.validatePassword(password, user.secrets.password);
await this.setLastSignedIn(user.email);
return user;
} catch {