diff --git a/@types/vite-env.d.ts b/@types/vite-env.d.ts index 97d9bb07..ef2a5ea0 100644 --- a/@types/vite-env.d.ts +++ b/@types/vite-env.d.ts @@ -2,6 +2,7 @@ interface ImportMetaEnv { readonly VITE_PACKAGE_VERSION: string; + readonly VITE_SENTRY_ENVIRONMENT: string; readonly VITE_BETA_BUILD?: 'true'; } diff --git a/package.json b/package.json index 94c6a257..8fcae1f8 100644 --- a/package.json +++ b/package.json @@ -10,7 +10,7 @@ "dev": "vite", "build": "tsc && vite build", "build:watch": "NODE_ENV='development' vite build --mode development -w", - "zip": "pnpm build && pnpm gulp zip", + "zip": "PROD=true pnpm build && pnpm gulp zip", "prettier": "prettier src --check", "prettier:fix": "prettier src --write", "lint": "eslint src --ext ts,tsx --report-unused-disable-directives", diff --git a/src/views/contexts/SentryContext.tsx b/src/views/contexts/SentryContext.tsx index 2b283820..69fda688 100644 --- a/src/views/contexts/SentryContext.tsx +++ b/src/views/contexts/SentryContext.tsx @@ -65,8 +65,9 @@ export default function SentryProvider({ integrations, transport: makeFetchTransport, stackParser: defaultStackParser, - // debug: true, + debug: import.meta.env.DEV, release: import.meta.env.VITE_PACKAGE_VERSION, + environment: import.meta.env.VITE_SENTRY_ENVIRONMENT, }; let client: Client; diff --git a/vite.config.ts b/vite.config.ts index 481eccfa..24cf11e4 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -22,6 +22,13 @@ if (isBeta) { process.env.VITE_BETA_BUILD = 'true'; } process.env.VITE_PACKAGE_VERSION = packageJson.version; +if (process.env.PROD) { + process.env.VITE_SENTRY_ENVIRONMENT = 'production'; +} else if (isBeta) { + process.env.VITE_SENTRY_ENVIRONMENT = 'beta'; +} else { + process.env.VITE_SENTRY_ENVIRONMENT = 'development'; +} export const preambleCode = ` import RefreshRuntime from "__BASE__@react-refresh" @@ -89,10 +96,13 @@ export default defineConfig({ apply: 'serve', transform(code, id) { if (id.endsWith('.tsx') || id.endsWith('.ts') || id.endsWith('?url')) { - return code.replace( - /(['"])(\/public\/.*?)(['"])/g, - (_, quote1, path, quote2) => `chrome.runtime.getURL(${quote1}${path}${quote2})` - ); + return { + code: code.replace( + /(['"])(\/public\/.*?)(['"])/g, + (_, quote1, path, quote2) => `chrome.runtime.getURL(${quote1}${path}${quote2})` + ), + map: null, + }; } }, }, @@ -101,10 +111,13 @@ export default defineConfig({ apply: 'build', transform(code, id) { if (id.endsWith('.tsx') || id.endsWith('.ts') || id.endsWith('?url')) { - return code.replace( - /(['"])(__VITE_ASSET__.*?__)(['"])/g, - (_, quote1, path, quote2) => `chrome.runtime.getURL(${quote1}${path}${quote2})` - ); + return { + code: code.replace( + /(['"])(__VITE_ASSET__.*?__)(['"])/g, + (_, quote1, path, quote2) => `chrome.runtime.getURL(${quote1}${path}${quote2})` + ), + map: null, + }; } }, }, @@ -114,13 +127,16 @@ export default defineConfig({ enforce: 'post', transform(code, id) { if (process.env.NODE_ENV === 'development' && (id.endsWith('.css') || id.endsWith('.scss'))) { - return code.replace( - /url\((.*?)\)/g, - (_, path) => - `url(\\"" + chrome.runtime.getURL(${path - .replaceAll(`\\"`, `"`) - .replace(/public\//, '')}) + "\\")` - ); + return { + code: code.replace( + /url\((.*?)\)/g, + (_, path) => + `url(\\"" + chrome.runtime.getURL(${path + .replaceAll(`\\"`, `"`) + .replace(/public\//, '')}) + "\\")` + ), + map: null, + }; } }, }, @@ -133,9 +149,8 @@ export default defineConfig({ /(__VITE_ASSET__.*?__)/g, (_, path) => `chrome-extension://__MSG_@@extension_id__${path}` ); - return transformedCode; + return { code: transformedCode, map: null }; } - return code; }, }, renameFile('src/pages/debug/index.html', 'debug.html'), @@ -143,7 +158,7 @@ export default defineConfig({ renameFile('src/pages/calendar/index.html', 'calendar.html'), renameFile('src/pages/report/index.html', 'report.html'), vitePluginRunCommandOnDemand({ - afterServerStart: 'pnpm gulp forceDisableUseDynamicUrl', + // afterServerStart: 'pnpm gulp forceDisableUseDynamicUrl', closeBundle: 'pnpm gulp forceDisableUseDynamicUrl', }), ], @@ -206,4 +221,11 @@ export default defineConfig({ provider: 'v8', }, }, + css: { + preprocessorOptions: { + scss: { + api: 'modern-compiler', + }, + }, + }, });