2023-05-23 15:28:48 +01:00
|
|
|
// Copyright (C) 2023 Storj Labs, Inc.
|
|
|
|
// See LICENSE for copying information.
|
|
|
|
|
|
|
|
import { resolve } from 'path';
|
|
|
|
|
|
|
|
import { defineConfig } from 'vite';
|
|
|
|
import { visualizer } from 'rollup-plugin-visualizer';
|
|
|
|
import vue from '@vitejs/plugin-vue';
|
|
|
|
import viteCompression from 'vite-plugin-compression';
|
|
|
|
import vitePluginRequire from 'vite-plugin-require';
|
|
|
|
import svgLoader from 'vite-svg-loader';
|
|
|
|
|
|
|
|
const productionBrotliExtensions = ['js', 'css', 'ttf', 'woff', 'woff2'];
|
|
|
|
|
|
|
|
const plugins = [
|
|
|
|
vue(),
|
|
|
|
svgLoader({
|
|
|
|
svgoConfig: {
|
|
|
|
plugins: [{ name: 'removeViewBox', fn: () => {} }],
|
|
|
|
},
|
|
|
|
}),
|
|
|
|
vitePluginRequire(),
|
|
|
|
];
|
|
|
|
|
|
|
|
if (process.env['STORJ_DEBUG_BUNDLE_SIZE']) {
|
|
|
|
plugins.push(visualizer({
|
|
|
|
template: 'treemap', // or sunburst
|
|
|
|
open: true,
|
|
|
|
brotliSize: true,
|
|
|
|
filename: 'analyse.html', // will be saved in project's root
|
|
|
|
}));
|
|
|
|
}
|
|
|
|
|
2023-07-27 11:17:46 +01:00
|
|
|
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('|') + ')$'),
|
|
|
|
}));
|
|
|
|
}
|
|
|
|
|
2023-05-23 15:28:48 +01:00
|
|
|
return {
|
|
|
|
base: '/static/dist',
|
|
|
|
plugins,
|
|
|
|
resolve: {
|
|
|
|
alias: {
|
|
|
|
'@': resolve(__dirname, './src'),
|
2023-08-16 09:34:46 +01:00
|
|
|
'@poc': resolve(__dirname, './vuetify-poc/src'),
|
2023-05-23 15:28:48 +01:00
|
|
|
'stream': 'stream-browserify',
|
|
|
|
'util': 'util/',
|
|
|
|
},
|
|
|
|
extensions: ['.js', '.ts', '.svg', '.vue'],
|
|
|
|
},
|
|
|
|
build: {
|
|
|
|
outDir: resolve(__dirname, 'dist'),
|
|
|
|
emptyOutDir: true,
|
|
|
|
rollupOptions: {
|
|
|
|
output: {
|
|
|
|
experimentalMinChunkSize: 50*1024,
|
|
|
|
},
|
|
|
|
},
|
2023-06-01 14:20:35 +01:00
|
|
|
chunkSizeWarningLimit: 3000,
|
2023-05-23 15:28:48 +01:00
|
|
|
},
|
|
|
|
define: {
|
|
|
|
'process.env': {},
|
2023-10-13 06:39:30 +01:00
|
|
|
__UI_TYPE__: JSON.stringify('legacy'),
|
2023-05-23 15:28:48 +01:00
|
|
|
},
|
|
|
|
test: {
|
|
|
|
globals: true,
|
|
|
|
environment: 'jsdom',
|
|
|
|
setupFiles: [
|
|
|
|
'./vitest.setup.ts',
|
|
|
|
],
|
|
|
|
exclude: [
|
|
|
|
'**/node_modules/**',
|
|
|
|
'**/dist/**',
|
|
|
|
'**/tests/unit/ignore/**',
|
|
|
|
],
|
|
|
|
},
|
|
|
|
};
|
|
|
|
});
|