fix: react-scan was included in production builds

This commit is contained in:
plebeius
2025-07-11 23:12:33 +02:00
parent 33fccc920b
commit a60142f493
3 changed files with 11 additions and 9 deletions

View File

@@ -35,7 +35,7 @@ jobs:
with:
node-version: 22
- name: Build React app (with Node v22)
run: CI='' yarn build
run: CI='' NODE_ENV=production yarn build
- name: Build Electron app for Linux (with Node v22)
run: yarn electron:build:linux
- name: List dist directory
@@ -82,7 +82,7 @@ jobs:
with:
node-version: 22
- name: Build React app (with Node v22)
run: CI='' yarn build
run: CI='' NODE_ENV=production yarn build
- name: Build Electron app for Mac (with Node v22)
run: yarn electron:build:mac
- name: List dist directory
@@ -116,7 +116,7 @@ jobs:
- name: Install dependencies (with Node v22) # --network-timeout and --network-concurrency are yarn v1 flags.
run: yarn install --frozen-lockfile --network-timeout 100000 --network-concurrency 1
- name: Build React app (with Node v22)
run: yarn build
run: NODE_ENV=production yarn build
- name: Build Electron app for Windows (with Node v22)
run: yarn electron:build:windows
- name: List dist directory
@@ -158,7 +158,7 @@ jobs:
- name: Install dependencies (with Node v20)
run: yarn install --frozen-lockfile --ignore-engines
# build react app
- run: CI='' yarn build
- run: CI='' NODE_ENV=production yarn build
# set android versionCode and versionName
- run: sed -i "s/versionCode 1/versionCode $(git tag | wc -l)/" ./android/app/build.gradle
- run: sed -i "s/versionName \"1.0\"/versionName \"$(node -e "console.log(require('./package.json').version)")\"/" ./android/app/build.gradle

View File

@@ -59,12 +59,12 @@
},
"scripts": {
"start": "vite",
"build": "cross-env PUBLIC_URL=./ GENERATE_SOURCEMAP=false vite build",
"build:preload": "vite build --config electron/vite.preload.config.js",
"build-netlify": "cross-env NODE_OPTIONS=\"--max_old_space_size=4096\" PUBLIC_URL=./ GENERATE_SOURCEMAP=true VITE_COMMIT_REF=$COMMIT_REF CI='' vite build",
"build": "cross-env NODE_ENV=production PUBLIC_URL=./ GENERATE_SOURCEMAP=false vite build",
"build:preload": "cross-env NODE_ENV=production vite build --config electron/vite.preload.config.js",
"build-netlify": "cross-env NODE_OPTIONS=\"--max_old_space_size=4096\" NODE_ENV=production PUBLIC_URL=./ GENERATE_SOURCEMAP=true VITE_COMMIT_REF=$COMMIT_REF CI='' vite build",
"test": "vitest",
"preview": "vite preview",
"analyze-bundle": "cross-env PUBLIC_URL=./ GENERATE_SOURCEMAP=true vite build && npx source-map-explorer 'build/assets/*.js'",
"analyze-bundle": "cross-env NODE_ENV=production PUBLIC_URL=./ GENERATE_SOURCEMAP=true vite build && npx source-map-explorer 'build/assets/*.js'",
"electron": "yarn build:preload && cross-env ELECTRON_IS_DEV=1 yarn electron:before && cross-env ELECTRON_IS_DEV=1 electron .",
"electron:no-delete-data": "yarn electron:before:download-ipfs && electron .",
"electron:start": "concurrently \"cross-env BROWSER=none yarn start\" \"wait-on http://localhost:3000 && yarn electron\"",

View File

@@ -7,6 +7,7 @@ import { VitePWA } from 'vite-plugin-pwa';
import reactScan from '@react-scan/vite-plugin-react-scan';
const isProduction = process.env.NODE_ENV === 'production';
const isDevelopment = process.env.NODE_ENV === 'development';
export default defineConfig({
plugins: [
@@ -19,7 +20,8 @@ export default defineConfig({
]
}
}),
!isProduction && reactScan({
// Only include React Scan in development mode - never in production builds
(isDevelopment || (!isProduction && process.env.NODE_ENV !== 'production')) && reactScan({
showToolbar: true,
playSound: true,
}),