2023-09-04 11:20:29 +00:00
|
|
|
import { sentryVitePlugin } from '@sentry/vite-plugin';
|
2023-09-11 15:26:44 +00:00
|
|
|
import { defineConfig, loadEnv, mergeConfig, Plugin } from 'vite';
|
|
|
|
|
2023-03-31 11:08:22 +00:00
|
|
|
import baseConfig from '../../packages/config/vite';
|
2021-09-22 06:27:02 +00:00
|
|
|
|
2023-03-31 11:08:22 +00:00
|
|
|
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);
|
2023-03-29 05:14:54 +00:00
|
|
|
}
|
2023-02-24 08:12:21 +00:00
|
|
|
}
|
2023-03-31 11:08:22 +00:00
|
|
|
return html;
|
2022-05-23 04:24:43 +00:00
|
|
|
}
|
2023-03-31 11:08:22 +00:00
|
|
|
};
|
|
|
|
|
2023-09-04 11:20:29 +00:00
|
|
|
export default defineConfig(({ mode }) => {
|
|
|
|
process.env = { ...process.env, ...loadEnv(mode, process.cwd(), '') };
|
|
|
|
|
|
|
|
return mergeConfig(baseConfig, {
|
|
|
|
server: {
|
|
|
|
port: 8001
|
|
|
|
},
|
2024-05-07 19:32:34 +00:00
|
|
|
build: {
|
|
|
|
rollupOptions: {
|
|
|
|
treeshake: 'recommended',
|
|
|
|
external: [
|
|
|
|
// Don't bundle Fda video for non-macOS platforms
|
|
|
|
process.platform !== 'darwin' && /^@sd\/assets\/videos\/Fda.mp4$/
|
|
|
|
].filter(Boolean)
|
|
|
|
}
|
|
|
|
},
|
2023-09-04 11:20:29 +00:00
|
|
|
plugins: [
|
|
|
|
devtoolsPlugin,
|
2023-09-29 04:58:29 +00:00
|
|
|
process.env.SENTRY_AUTH_TOKEN &&
|
|
|
|
sentryVitePlugin({
|
|
|
|
authToken: process.env.SENTRY_AUTH_TOKEN,
|
|
|
|
org: 'spacedriveapp',
|
|
|
|
project: 'desktop'
|
|
|
|
})
|
2023-09-04 11:20:29 +00:00
|
|
|
]
|
|
|
|
});
|
2021-09-22 06:27:02 +00:00
|
|
|
});
|