web/satellite: fix build-watch

Build-watch is broken again since we don't use NODE_ENV variable anymore.
Adjusted code to work with 'mode' setting.

Change-Id: I08b19ef59b39e6b14ce05d7340f032ee8377c49c
This commit is contained in:
Vitalii 2023-07-27 13:17:46 +03:00 committed by Storj Robot
parent c934974652
commit fcbb37fb66
2 changed files with 12 additions and 11 deletions

View File

@ -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));

View File

@ -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,