feature/IO-3255-simplified-parts-management - Cleanup / Bug fixes

This commit is contained in:
Dave
2025-08-21 14:57:55 -04:00
parent 43d5a77d60
commit 6942d6e4f9
6 changed files with 310 additions and 58 deletions

View File

@@ -1,5 +1,4 @@
/* eslint-disable */
import { sentryVitePlugin } from "@sentry/vite-plugin";
import react from "@vitejs/plugin-react";
import chalk from "chalk";
@@ -10,21 +9,23 @@ import { ViteEjsPlugin } from "vite-plugin-ejs";
import eslint from "vite-plugin-eslint";
import { VitePWA } from "vite-plugin-pwa";
import InstanceRenderManager from "./src/utils/instanceRenderMgr";
import browserslist from "browserslist";
import { browserslistToTargets } from "lightningcss";
// Ensure your environment variables are set correctly for Vite 6
process.env.VITE_APP_GIT_SHA_DATE = new Date().toLocaleString("en-US", {
timeZone: "America/Los_Angeles"
});
process.env.VITE_APP_GIT_SHA_DATE = new Date().toLocaleString("en-US", { timeZone: "America/Los_Angeles" });
const commitHash = child.execSync("git rev-parse HEAD").toString().trimEnd();
process.env.VITE_GIT_COMMIT_HASH = commitHash;
const currentDatePST = new Date()
.toLocaleDateString("en-US", {
timeZone: "America/Los_Angeles",
year: "numeric",
month: "2-digit",
day: "2-digit"
// Resolve browserslist from package.json and map to Lightning CSS targets
const lightningCssTargets = browserslistToTargets(
browserslist(undefined, {
path: process.cwd(),
env: process.env.NODE_ENV === "production" ? "production" : "development"
})
);
const currentDatePST = new Date()
.toLocaleDateString("en-US", { timeZone: "America/Los_Angeles", year: "numeric", month: "2-digit", day: "2-digit" })
.split("/")
.reverse()
.join("-");
@@ -32,18 +33,21 @@ const currentDatePST = new Date()
const getFormattedTimestamp = () =>
new Date().toLocaleTimeString("en-US", { hour12: true }).replace("AM", "a.m.").replace("PM", "p.m.");
export const logger = createLogger("info", {
allowClearScreen: false
});
export const logger = createLogger("info", { allowClearScreen: false });
export default defineConfig({
base: "/",
plugins: [
// Ensure all plugins are Vite 6 compatible
ViteEjsPlugin((viteConfig) => ({ env: viteConfig.env })),
// PWA only for production builds (faster dev)
VitePWA({
apply: "build",
injectRegister: "auto",
registerType: "prompt",
workbox: {
navigateFallbackDenylist: [/^\/api\//] // prevent caching API routes
},
manifest: {
short_name: InstanceRenderManager({
instance: process.env.VITE_APP_INSTANCE,
@@ -94,13 +98,15 @@ export default defineConfig({
gcm_sender_id: "103953800507"
}
}),
react(),
eslint(),
// Sentry only for production builds (no dev overhead)
sentryVitePlugin({
apply: "build",
org: "imex",
reactComponentAnnotation: {
enabled: true
},
reactComponentAnnotation: { enabled: true },
release: {
name: `${process.env.VITE_APP_IS_TEST ? "test" : "production"}-${currentDatePST}-${commitHash}`.trim()
},
@@ -111,10 +117,12 @@ export default defineConfig({
})
})
],
define: {
APP_VERSION: JSON.stringify(process.env.npm_package_version),
__COMMIT_HASH__: JSON.stringify(commitHash)
},
server: {
host: true,
port: 3000,
@@ -122,13 +130,11 @@ export default defineConfig({
proxy: {
"/ws": {
target: "ws://localhost:4000",
rewriteWsOrigin: true,
secure: false,
ws: true
},
"/wss": {
target: "ws://localhost:4000",
rewriteWsOrigin: true,
secure: false,
ws: true
},
@@ -148,18 +154,17 @@ export default defineConfig({
},
https: {
key: await fsPromises.readFile("../certs/key.pem"),
cert: await fsPromises.readFile("../certs/cert.pem"),
allowHTTP1: false // Force HTTP/2
cert: await fsPromises.readFile("../certs/cert.pem")
}
},
preview: {
port: 6000,
host: true,
open: true,
https: {
key: await fsPromises.readFile("../certs/key.pem"),
cert: await fsPromises.readFile("../certs/cert.pem"),
allowHTTP1: false // Force HTTP/2
cert: await fsPromises.readFile("../certs/cert.pem")
},
proxy: {
"/ws": {
@@ -182,7 +187,11 @@ export default defineConfig({
}
}
},
build: {
// Hide source maps from browsers; Sentry plugin will upload them
sourcemap: "hidden",
rollupOptions: {
output: {
manualChunks: {
@@ -207,8 +216,14 @@ export default defineConfig({
}
},
sourcemap: true
cssMinify: "lightningcss"
},
// Strip console/debugger in prod to shrink bundles
esbuild: {
drop: ["console", "debugger"]
},
optimizeDeps: {
include: [
"react",
@@ -231,19 +246,17 @@ export default defineConfig({
"@firebase/util"
],
esbuildOptions: {
// Update for Vite 6: Use proper file extensions
loader: {
".jsx": "jsx",
".tsx": "tsx"
}
loader: { ".jsx": "jsx", ".tsx": "tsx" }
}
},
css: {
transformer: "lightningcss",
lightningcss: {
targets: lightningCssTargets
},
preprocessorOptions: {
scss: {
api: "modern-compiler",
quietDeps: true // Quite Deprecation Warnings, should be disabled occasionally before major upgrades
}
scss: { quietDeps: true }
}
}
});