mirror of
https://github.com/Frooodle/Stirling-PDF.git
synced 2026-03-04 02:20:19 +01:00
# Summary - Adds desktop file tracking: local paths are preserved and save buttons now work as expcted (doing Save/Save As as appropriate) - Adds logic to track whether files are 'dirty' (they've been modified by some tool, and not saved to disk yet). - Improves file state UX (dirty vs saved) and close warnings - Web behaviour should be unaffected by these changes ## Indicators Files now have indicators in desktop mode to tell you their state. ### File up-to-date with disk <img width="318" height="393" alt="image" src="https://github.com/user-attachments/assets/06325f9a-afd7-4c2f-8a5b-6d11e3093115" /> ### File modified by a tool but not saved to disk yet <img width="357" height="385" alt="image" src="https://github.com/user-attachments/assets/1a7716d9-c6f7-4d13-be0d-c1de6493954b" /> ### File not tracked on disk <img width="312" height="379" alt="image" src="https://github.com/user-attachments/assets/9cffe300-bd9a-4e19-97c7-9b98bebefacc" /> # Limitations - It's a bit weird that we still have files stored in indexeddb in the app, which are still loadable. We might want to change this behaviour in the future - Viewer's Save doesn't persist to disk. I've left that out here because it'd need a lot of testing to make sure the logic's right with making sure you can leave the Viewer with applying the changes to the PDF _without_ saving to disk - There's no current way to do Save As on a file that has already been persisted to disk - it's only ever Save. Similarly, there's no way to duplicate a file. --------- Co-authored-by: James Brunton <jbrunton96@gmail.com> Co-authored-by: James Brunton <james@stirlingpdf.com>
114 lines
3.4 KiB
TypeScript
114 lines
3.4 KiB
TypeScript
import { defineConfig } from 'vite';
|
|
import react from '@vitejs/plugin-react-swc';
|
|
import tsconfigPaths from 'vite-tsconfig-paths';
|
|
import { viteStaticCopy } from 'vite-plugin-static-copy';
|
|
|
|
export default defineConfig(({ mode }) => {
|
|
// When DISABLE_ADDITIONAL_FEATURES is false (or unset), enable proprietary features
|
|
const isProprietary = process.env.DISABLE_ADDITIONAL_FEATURES !== 'true';
|
|
const isDesktopMode =
|
|
mode === 'desktop' ||
|
|
process.env.STIRLING_DESKTOP === 'true' ||
|
|
process.env.VITE_DESKTOP === 'true';
|
|
|
|
// Validate required environment variables for desktop builds
|
|
if (isDesktopMode) {
|
|
const requiredEnvVars = [
|
|
'VITE_SAAS_SERVER_URL',
|
|
'VITE_SUPABASE_PUBLISHABLE_DEFAULT_KEY',
|
|
];
|
|
|
|
const missingVars = requiredEnvVars.filter(varName => !process.env[varName]);
|
|
|
|
if (missingVars.length > 0) {
|
|
throw new Error(
|
|
`Desktop build failed: Missing required environment variables:\n${missingVars.map(v => ` - ${v}`).join('\n')}\n\nPlease set these variables before building the desktop app.`
|
|
);
|
|
}
|
|
}
|
|
|
|
const baseProject = isProprietary ? './tsconfig.proprietary.vite.json' : './tsconfig.core.vite.json';
|
|
const desktopProject = isProprietary ? './tsconfig.desktop.vite.json' : baseProject;
|
|
const tsconfigProject = isDesktopMode ? desktopProject : baseProject;
|
|
|
|
return {
|
|
plugins: [
|
|
react(),
|
|
tsconfigPaths({
|
|
projects: [tsconfigProject],
|
|
}),
|
|
viteStaticCopy({
|
|
targets: [
|
|
{
|
|
//provides static pdfium so embedpdf can run without cdn
|
|
src: 'node_modules/@embedpdf/pdfium/dist/pdfium.wasm',
|
|
dest: 'pdfium'
|
|
},
|
|
{
|
|
// Copy jscanify vendor files to dist
|
|
src: 'public/vendor/jscanify/*',
|
|
dest: 'vendor/jscanify'
|
|
}
|
|
]
|
|
})
|
|
],
|
|
server: {
|
|
host: true,
|
|
// make sure this port matches the devUrl port in tauri.conf.json file
|
|
port: 5173,
|
|
// Tauri expects a fixed port, fail if that port is not available
|
|
strictPort: true,
|
|
watch: {
|
|
// tell vite to ignore watching `src-tauri`
|
|
ignored: ['**/src-tauri/**'],
|
|
},
|
|
// Only use proxy in web mode - Tauri handles backend connections directly
|
|
proxy: isDesktopMode ? undefined : {
|
|
'/api': {
|
|
target: 'http://localhost:8080',
|
|
changeOrigin: true,
|
|
secure: false,
|
|
xfwd: true,
|
|
},
|
|
'/oauth2': {
|
|
target: 'http://localhost:8080',
|
|
changeOrigin: true,
|
|
secure: false,
|
|
xfwd: true,
|
|
},
|
|
'/saml2': {
|
|
target: 'http://localhost:8080',
|
|
changeOrigin: true,
|
|
secure: false,
|
|
xfwd: true,
|
|
},
|
|
'/login/oauth2': {
|
|
target: 'http://localhost:8080',
|
|
changeOrigin: true,
|
|
secure: false,
|
|
xfwd: true,
|
|
},
|
|
'/login/saml2': {
|
|
target: 'http://localhost:8080',
|
|
changeOrigin: true,
|
|
secure: false,
|
|
xfwd: true,
|
|
},
|
|
'/swagger-ui': {
|
|
target: 'http://localhost:8080',
|
|
changeOrigin: true,
|
|
secure: false,
|
|
xfwd: true,
|
|
},
|
|
'/v1/api-docs': {
|
|
target: 'http://localhost:8080',
|
|
changeOrigin: true,
|
|
secure: false,
|
|
xfwd: true,
|
|
},
|
|
},
|
|
},
|
|
base: process.env.RUN_SUBPATH ? `/${process.env.RUN_SUBPATH}` : './',
|
|
};
|
|
});
|