mirror of
https://github.com/spacedriveapp/spacedrive
synced 2024-07-02 11:13:29 +00:00
81c2b8bf51
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
48 lines
1.2 KiB
TypeScript
48 lines
1.2 KiB
TypeScript
import { sentryVitePlugin } from '@sentry/vite-plugin';
|
|
import { defineConfig, loadEnv, mergeConfig, Plugin } from 'vite';
|
|
|
|
import baseConfig from '../../packages/config/vite';
|
|
|
|
const devtoolsPlugin: Plugin = {
|
|
name: 'devtools-plugin',
|
|
transformIndexHtml(html) {
|
|
const isDev = process.env.NODE_ENV === 'development';
|
|
if (isDev) {
|
|
const devtoolsScript = `<script src="http://localhost:8097"></script>`;
|
|
const headTagIndex = html.indexOf('</head>');
|
|
if (headTagIndex > -1) {
|
|
return html.slice(0, headTagIndex) + devtoolsScript + html.slice(headTagIndex);
|
|
}
|
|
}
|
|
return html;
|
|
}
|
|
};
|
|
|
|
export default defineConfig(({ mode }) => {
|
|
process.env = { ...process.env, ...loadEnv(mode, process.cwd(), '') };
|
|
|
|
return mergeConfig(baseConfig, {
|
|
server: {
|
|
port: 8001
|
|
},
|
|
build: {
|
|
rollupOptions: {
|
|
treeshake: 'recommended',
|
|
external: [
|
|
// Don't bundle Fda video for non-macOS platforms
|
|
process.platform !== 'darwin' && /^@sd\/assets\/videos\/Fda.mp4$/
|
|
].filter(Boolean)
|
|
}
|
|
},
|
|
plugins: [
|
|
devtoolsPlugin,
|
|
process.env.SENTRY_AUTH_TOKEN &&
|
|
sentryVitePlugin({
|
|
authToken: process.env.SENTRY_AUTH_TOKEN,
|
|
org: 'spacedriveapp',
|
|
project: 'desktop'
|
|
})
|
|
]
|
|
});
|
|
});
|