| 
									
										
										
										
											2025-05-16 20:48:29 +03:00
										 |  |  | /// <reference types='vitest' />
 | 
					
						
							| 
									
										
										
										
											2025-05-20 18:06:55 +03:00
										 |  |  | import { join, resolve } from 'path'; | 
					
						
							| 
									
										
										
										
											2025-04-22 22:06:10 +03:00
										 |  |  | import { defineConfig } from 'vite'; | 
					
						
							| 
									
										
										
										
											2025-05-16 21:31:57 +03:00
										 |  |  | import { viteStaticCopy } from 'vite-plugin-static-copy' | 
					
						
							| 
									
										
										
										
											2025-05-19 19:51:33 +03:00
										 |  |  | import asset_path from './src/asset_path'; | 
					
						
							| 
									
										
										
										
											2025-06-07 13:02:37 +03:00
										 |  |  | import webpackStatsPlugin from 'rollup-plugin-webpack-stats'; | 
					
						
							| 
									
										
										
										
											2025-05-16 21:31:57 +03:00
										 |  |  | 
 | 
					
						
							|  |  |  | const assets = [ "assets", "stylesheets", "libraries", "fonts", "translations" ]; | 
					
						
							| 
									
										
										
										
											2025-04-22 22:06:10 +03:00
										 |  |  | 
 | 
					
						
							|  |  |  | export default defineConfig(() => ({ | 
					
						
							| 
									
										
										
										
											2025-04-26 23:03:16 +03:00
										 |  |  |     root: __dirname, | 
					
						
							|  |  |  |     cacheDir: '../../node_modules/.vite/apps/client', | 
					
						
							| 
									
										
										
										
											2025-06-06 22:57:00 +03:00
										 |  |  |     base: process.env.NODE_ENV === "production" ? "" : asset_path, | 
					
						
							| 
									
										
										
										
											2025-05-16 20:48:29 +03:00
										 |  |  |     server: { | 
					
						
							|  |  |  |         port: 4200, | 
					
						
							|  |  |  |         host: 'localhost', | 
					
						
							|  |  |  |     }, | 
					
						
							|  |  |  |     preview: { | 
					
						
							|  |  |  |         port: 4300, | 
					
						
							|  |  |  |         host: 'localhost', | 
					
						
							|  |  |  |     }, | 
					
						
							| 
									
										
										
										
											2025-05-16 21:31:57 +03:00
										 |  |  |     plugins: [ | 
					
						
							|  |  |  |         viteStaticCopy({ | 
					
						
							|  |  |  |             targets: assets.map((asset) => ({ | 
					
						
							| 
									
										
										
										
											2025-05-26 18:14:47 +03:00
										 |  |  |                 src: `src/${asset}/*`, | 
					
						
							| 
									
										
										
										
											2025-05-16 21:31:57 +03:00
										 |  |  |                 dest: asset | 
					
						
							|  |  |  |             })) | 
					
						
							| 
									
										
										
										
											2025-05-17 19:52:04 +03:00
										 |  |  |         }), | 
					
						
							|  |  |  |         viteStaticCopy({ | 
					
						
							|  |  |  |             structured: true, | 
					
						
							|  |  |  |             targets: [ | 
					
						
							|  |  |  |                 { | 
					
						
							|  |  |  |                     src: "node_modules/@excalidraw/excalidraw/dist/prod/fonts/*", | 
					
						
							|  |  |  |                     dest: "", | 
					
						
							|  |  |  |                 } | 
					
						
							|  |  |  |             ] | 
					
						
							| 
									
										
										
										
											2025-06-07 13:02:37 +03:00
										 |  |  |         }), | 
					
						
							|  |  |  |         webpackStatsPlugin() | 
					
						
							| 
									
										
										
										
											2025-05-16 21:31:57 +03:00
										 |  |  |     ], | 
					
						
							| 
									
										
										
										
											2025-05-20 18:06:55 +03:00
										 |  |  |     resolve: { | 
					
						
							|  |  |  |         alias: [ | 
					
						
							|  |  |  |             // Force the use of dist in development mode because upstream ESM is broken (some hybrid between CJS and ESM, will be improved in upcoming versions).
 | 
					
						
							|  |  |  |             { | 
					
						
							|  |  |  |                 find: "@triliumnext/highlightjs", | 
					
						
							|  |  |  |                 replacement: resolve(__dirname, "node_modules/@triliumnext/highlightjs/dist") | 
					
						
							| 
									
										
										
										
											2025-06-10 22:22:47 +03:00
										 |  |  |             }, | 
					
						
							|  |  |  |             { | 
					
						
							|  |  |  |                 find: "react", | 
					
						
							|  |  |  |                 replacement: "preact/compat" | 
					
						
							|  |  |  |             }, | 
					
						
							|  |  |  |             { | 
					
						
							|  |  |  |                 find: "react-dom", | 
					
						
							|  |  |  |                 replacement: "preact/compat" | 
					
						
							| 
									
										
										
										
											2025-05-20 18:06:55 +03:00
										 |  |  |             } | 
					
						
							| 
									
										
										
										
											2025-06-10 21:23:46 +03:00
										 |  |  |         ], | 
					
						
							|  |  |  |         dedupe: [ | 
					
						
							|  |  |  |             "react", | 
					
						
							| 
									
										
										
										
											2025-06-10 22:22:47 +03:00
										 |  |  |             "react-dom", | 
					
						
							|  |  |  |             "preact", | 
					
						
							|  |  |  |             "preact/compat", | 
					
						
							|  |  |  |             "preact/hooks" | 
					
						
							| 
									
										
										
										
											2025-05-20 18:06:55 +03:00
										 |  |  |         ] | 
					
						
							|  |  |  |     }, | 
					
						
							| 
									
										
										
										
											2025-05-16 20:48:29 +03:00
										 |  |  |     // Uncomment this if you are using workers.
 | 
					
						
							|  |  |  |     // worker: {
 | 
					
						
							|  |  |  |     //  plugins: [ nxViteTsPaths() ],
 | 
					
						
							|  |  |  |     // },
 | 
					
						
							|  |  |  |     build: { | 
					
						
							| 
									
										
										
										
											2025-05-16 21:06:30 +03:00
										 |  |  |         target: "esnext", | 
					
						
							| 
									
										
										
										
											2025-05-16 20:48:29 +03:00
										 |  |  |         outDir: './dist', | 
					
						
							|  |  |  |         emptyOutDir: true, | 
					
						
							|  |  |  |         reportCompressedSize: true, | 
					
						
							| 
									
										
										
										
											2025-06-07 20:12:13 +03:00
										 |  |  |         sourcemap: process.env.NODE_ENV === "production", | 
					
						
							| 
									
										
										
										
											2025-05-16 20:48:29 +03:00
										 |  |  |         rollupOptions: { | 
					
						
							|  |  |  |             input: { | 
					
						
							|  |  |  |                 desktop: join(__dirname, "src", "desktop.ts"), | 
					
						
							|  |  |  |                 mobile: join(__dirname, "src", "mobile.ts"), | 
					
						
							|  |  |  |                 login: join(__dirname, "src", "login.ts"), | 
					
						
							|  |  |  |                 setup: join(__dirname, "src", "setup.ts"), | 
					
						
							|  |  |  |                 share: join(__dirname, "src", "share.ts"), | 
					
						
							|  |  |  |                 set_password: join(__dirname, "src", "set_password.ts"), | 
					
						
							| 
									
										
										
										
											2025-05-18 00:01:53 +03:00
										 |  |  |                 runtime: join(__dirname, "src", "runtime.ts") | 
					
						
							| 
									
										
										
										
											2025-05-16 21:11:03 +03:00
										 |  |  |             }, | 
					
						
							|  |  |  |             output: { | 
					
						
							| 
									
										
										
										
											2025-05-19 20:04:51 +03:00
										 |  |  |                 entryFileNames: "src/[name].js", | 
					
						
							|  |  |  |                 chunkFileNames: "src/[name].js", | 
					
						
							| 
									
										
										
										
											2025-05-20 12:29:36 +03:00
										 |  |  |                 assetFileNames: "src/[name].[ext]" | 
					
						
							| 
									
										
										
										
											2025-05-17 23:53:58 +03:00
										 |  |  |             }, | 
					
						
							|  |  |  |             onwarn(warning, rollupWarn) { | 
					
						
							|  |  |  |                 if (warning.code === "MODULE_LEVEL_DIRECTIVE") { | 
					
						
							|  |  |  |                     return; | 
					
						
							|  |  |  |                 } | 
					
						
							|  |  |  |                 rollupWarn(warning); | 
					
						
							| 
									
										
										
										
											2025-05-16 20:48:29 +03:00
										 |  |  |             } | 
					
						
							| 
									
										
										
										
											2025-04-26 23:03:16 +03:00
										 |  |  |         } | 
					
						
							|  |  |  |     }, | 
					
						
							| 
									
										
										
										
											2025-05-20 12:12:31 +03:00
										 |  |  |     optimizeDeps: { | 
					
						
							|  |  |  |         exclude: [ | 
					
						
							|  |  |  |             "@triliumnext/highlightjs" | 
					
						
							|  |  |  |         ] | 
					
						
							|  |  |  |     }, | 
					
						
							| 
									
										
										
										
											2025-05-17 23:50:44 +03:00
										 |  |  |     css: { | 
					
						
							|  |  |  |         preprocessorOptions: { | 
					
						
							|  |  |  |             scss: { | 
					
						
							|  |  |  |                 quietDeps: true | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |     }, | 
					
						
							| 
									
										
										
										
											2025-05-16 20:48:29 +03:00
										 |  |  |     commonjsOptions: { | 
					
						
							|  |  |  |         transformMixedEsModules: true, | 
					
						
							| 
									
										
										
										
											2025-06-10 22:22:47 +03:00
										 |  |  |     }, | 
					
						
							|  |  |  |     define: { | 
					
						
							|  |  |  |         "process.env.IS_PREACT": JSON.stringify("true"), | 
					
						
							| 
									
										
										
										
											2025-05-16 20:48:29 +03:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2025-04-22 22:06:10 +03:00
										 |  |  | })); |