spacedrive/packages/config/vite/index.ts
Vítor Vasconcellos 81c2b8bf51
Improve prod bundle size (#2447)
Greatly improve production build size, now prod builds are 1/3 of the size
 - Main spacedrive binary went from ~120M to ~40M
 - Add more optimize options for rust prod build
 - Improve vite settings for front-end prod build
 - Improve lossless compression of PNGs
 - Don't include videos in bundles when they are not used
 - Don't generate/bundle sourcemap for prod builds
2024-05-07 19:32:34 +00:00

42 lines
1.1 KiB
TypeScript

import { fileURLToPath } from 'node:url';
import ts from '@babel/preset-typescript';
import react from '@vitejs/plugin-react-swc';
import million from 'million/compiler';
import { defineConfig } from 'vite';
import { createHtmlPlugin } from 'vite-plugin-html';
import i18nextLoader from 'vite-plugin-i18next-loader';
import svg from 'vite-plugin-svgr';
import tsconfigPaths from 'vite-tsconfig-paths';
import { narrowSolidPlugin } from './narrowSolidPlugin';
const url = new URL('../../../interface/locales', import.meta.url);
export default defineConfig({
plugins: [
million.vite({ auto: true }),
tsconfigPaths(),
i18nextLoader({
paths: [fileURLToPath(url.href)],
namespaceResolution: 'relativePath'
}),
react(),
narrowSolidPlugin({ include: '**/*.solid.tsx', babel: { presets: [[ts, {}]] } }),
svg({ svgrOptions: { icon: true } }),
createHtmlPlugin({
minify: true
})
],
css: {
modules: {
localsConvention: 'camelCaseOnly'
}
},
root: 'src',
build: {
sourcemap: process.env.GENERATE_SOURCEMAP === 'false' ? false : true,
outDir: '../dist',
assetsDir: '.'
}
});