diff --git a/.storybook/main.ts b/.storybook/main.ts index 5b7c126e9..90fbb138a 100644 --- a/.storybook/main.ts +++ b/.storybook/main.ts @@ -96,15 +96,15 @@ const config: StorybookConfig = { } ] }, - esbuild: { - // Prevent minification of identifiers to preserve _sfc_main - minifyIdentifiers: false, - keepNames: true - }, build: { - rollupOptions: { - // Disable tree-shaking for Storybook to prevent Vue SFC exports from being removed + rolldownOptions: { + experimental: { + strictExecutionOrder: true + }, treeshake: false, + output: { + keepNames: true + }, onwarn: (warning, warn) => { // Suppress specific warnings if ( diff --git a/apps/desktop-ui/vite.config.mts b/apps/desktop-ui/vite.config.mts index 7cbc5307d..771f0f85b 100644 --- a/apps/desktop-ui/vite.config.mts +++ b/apps/desktop-ui/vite.config.mts @@ -64,7 +64,7 @@ export default defineConfig(() => { }) ], build: { - minify: SHOULD_MINIFY ? ('esbuild' as const) : false, + minify: SHOULD_MINIFY, target: 'es2022', sourcemap: true } diff --git a/vite.config.mts b/vite.config.mts index abfce8f35..e3246e608 100644 --- a/vite.config.mts +++ b/vite.config.mts @@ -412,77 +412,83 @@ export default defineConfig({ ], build: { - minify: SHOULD_MINIFY ? 'esbuild' : false, + minify: SHOULD_MINIFY, target: 'es2022', sourcemap: GENERATE_SOURCEMAP, - rollupOptions: { - treeshake: true, - output: { - manualChunks: (id) => { - if (!id.includes('node_modules')) { - return undefined - } - - if (id.includes('primevue') || id.includes('@primeuix')) { - return 'vendor-primevue' - } - - if (id.includes('@tiptap')) { - return 'vendor-tiptap' - } - - if (id.includes('chart.js')) { - return 'vendor-chart' - } - - if (id.includes('three') || id.includes('@sparkjsdev')) { - return 'vendor-three' - } - - if (id.includes('@xterm')) { - return 'vendor-xterm' - } - - if (id.includes('/vue') || id.includes('pinia')) { - return 'vendor-vue' - } - if (id.includes('reka-ui')) { - return 'vendor-reka-ui' - } - - return 'vendor-other' - } - } - } - }, - - esbuild: { - minifyIdentifiers: SHOULD_MINIFY, - keepNames: true, - minifySyntax: SHOULD_MINIFY, - minifyWhitespace: SHOULD_MINIFY, - pure: SHOULD_MINIFY - ? [ - 'console.log', + rolldownOptions: { + treeshake: { + manualPureFunctions: [ + 'console.clear', + 'console.count', + 'console.countReset', 'console.debug', - 'console.info', - 'console.trace', 'console.dir', 'console.dirxml', 'console.group', 'console.groupCollapsed', 'console.groupEnd', + 'console.info', + 'console.log', + 'console.profile', + 'console.profileEnd', 'console.table', 'console.time', 'console.timeEnd', 'console.timeLog', - 'console.count', - 'console.countReset', - 'console.profile', - 'console.profileEnd', - 'console.clear' + 'console.trace' ] - : [] + }, + experimental: { + strictExecutionOrder: true + }, + output: { + keepNames: true, + codeSplitting: { + groups: [ + { + name: 'vendor-primevue', + test: /[\\/]node_modules[\\/](@?primevue|@primeuix)[\\/]/, + priority: 10 + }, + { + name: 'vendor-tiptap', + test: /[\\/]node_modules[\\/]@tiptap[\\/]/, + priority: 10 + }, + { + name: 'vendor-chart', + test: /[\\/]node_modules[\\/]chart\.js[\\/]/, + priority: 10 + }, + { + name: 'vendor-three', + test: /[\\/]node_modules[\\/](three|@sparkjsdev)[\\/]/, + priority: 10 + }, + { + name: 'vendor-xterm', + test: /[\\/]node_modules[\\/]@xterm[\\/]/, + priority: 10 + }, + { + name: 'vendor-vue', + test: /[\\/]node_modules[\\/](vue|pinia)[\\/]/, + priority: 10 + }, + { + name: 'vendor-reka-ui', + test: /[\\/]node_modules[\\/]reka-ui[\\/]/, + priority: 10 + }, + { + name: 'vendor-other', + test: /[\\/]node_modules[\\/]/, + priority: 0 + } + ] + } + } + } }, define: {