diff --git a/web/satellite/src/store/modules/accessGrantsStore.ts b/web/satellite/src/store/modules/accessGrantsStore.ts index c43277faa..c25e015d1 100644 --- a/web/satellite/src/store/modules/accessGrantsStore.ts +++ b/web/satellite/src/store/modules/accessGrantsStore.ts @@ -46,7 +46,7 @@ export const useAccessGrantsStore = defineStore('accessGrants', () => { // TODO(vitalii): create an issue here https://github.com/vitejs/vite // about worker chunk being auto removed after rebuild in watch mode if using new URL constructor. let worker: Worker; - if (process.env.NODE_ENV === 'development') { + if (import.meta.env.MODE === 'development') { worker = new Worker('/static/src/utils/accessGrant.worker.js'); } else { worker = new Worker(new URL('@/utils/accessGrant.worker.js', import.meta.url)); diff --git a/web/satellite/vite.config.js b/web/satellite/vite.config.js index 3ec83c64a..9f4c19af0 100644 --- a/web/satellite/vite.config.js +++ b/web/satellite/vite.config.js @@ -22,15 +22,6 @@ const plugins = [ vitePluginRequire(), ]; -if (process.env.NODE_ENV === 'production') { - plugins.push(viteCompression({ - algorithm: 'brotliCompress', - threshold: 1024, - ext: '.br', - filter: new RegExp('\\.(' + productionBrotliExtensions.join('|') + ')$'), - })); -} - if (process.env['STORJ_DEBUG_BUNDLE_SIZE']) { plugins.push(visualizer({ template: 'treemap', // or sunburst @@ -40,7 +31,17 @@ if (process.env['STORJ_DEBUG_BUNDLE_SIZE']) { })); } -export default defineConfig(() => { +export default defineConfig(({ mode }) => { + // compress chunks only for production mode builds. + if (mode === 'production') { + plugins.push(viteCompression({ + algorithm: 'brotliCompress', + threshold: 1024, + ext: '.br', + filter: new RegExp('\\.(' + productionBrotliExtensions.join('|') + ')$'), + })); + } + return { base: '/static/dist', plugins,