Skip to content

Commit

Permalink
Remove logging from production build workers
Browse files Browse the repository at this point in the history
  • Loading branch information
mrdjohnson committed Feb 23, 2024
1 parent 7ff2001 commit 635c879
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 4 deletions.
9 changes: 8 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
"typescript": "^5.2.2",
"vite": "^5.1.0",
"vite-plugin-mkcert": "^1.17.3",
"vite-plugin-pwa": "^0.19.0"
"vite-plugin-pwa": "^0.19.0",
"vite-plugin-remove-console": "^2.2.0"
}
}
12 changes: 10 additions & 2 deletions vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import react from '@vitejs/plugin-react'
import { VitePWA, VitePWAOptions } from 'vite-plugin-pwa'
import mkcert from 'vite-plugin-mkcert'
import replace from '@rollup/plugin-replace'
import removeConsole from 'vite-plugin-remove-console'

const replaceOptions = { __DATE__: new Date().toISOString(), __RELOAD_SW__: 'false' }

Expand All @@ -11,11 +12,12 @@ const isDev = process.env.NODE_ENV === 'development'
const makeCert = isDev ? mkcert() : undefined

const pwaOptions: Partial<VitePWAOptions> = {
mode: 'development',
mode: 'production',
base: '/llm-x/',
includeAssets: ['favicon.svg'],
workbox: {
globPatterns: ['**/*'],
disableDevLogs: true,
},
manifest: {
name: 'LLM-X Dev Version',
Expand Down Expand Up @@ -70,10 +72,16 @@ if (selfDestroying) pwaOptions.selfDestroying = selfDestroying

// https://vitejs.dev/config/
export default defineConfig({
plugins: [react(), makeCert, VitePWA(pwaOptions), replace(replaceOptions)],
plugins: [react(), makeCert, VitePWA(pwaOptions), replace(replaceOptions), removeConsole()],
esbuild: {
// https://github.com/vitejs/vite/discussions/7920#discussioncomment-2709119
drop: isDev ? [] : ['console', 'debugger'],
logLevel: 'silent',
},
base: '/llm-x/',
worker: {
rollupOptions: {
logLevel: 'silent',
},
},
})

0 comments on commit 635c879

Please sign in to comment.