Skip to content

Ignored settings for rolldown-vite #28

@crystalfp

Description

@crystalfp

I build my application under rolldown-vite in preparation to migrate to vite v8.
My vite.config.ts splits node_modules into 3 chunks.

dist/assets/index-Arr-iP9r.js                     260.03 kB
dist/assets/three-XjS5uQZu.js                     736.26 kB
dist/assets/vue-D-vnJB8U.js                       820.53 kB

Instead the bundle analyzer ignores the rolldownOptions and bundle node modules into a single chunk:

dist/assets/index-Daee3H7g.js                   1,435.53 kB

Hence the result does not reflect reality.
My vite.config.ts is:

import {defineConfig} from "rolldown-vite";
import electron from "vite-plugin-electron";
import renderer from "vite-plugin-electron-renderer";
import vueDevTools from "vite-plugin-vue-devtools";
import cleanPlugin from "vite-plugin-clean-pattern";
import vue from "@vitejs/plugin-vue";
import {fileURLToPath, URL} from "node:url";

export default defineConfig({
    resolve: {
        alias: {
            "@": fileURLToPath(new URL("src", import.meta.url))
        },
        preserveSymlinks: true
    },
    optimizeDeps: {
        exclude: [".git", ".vscode", "doc", "release", "save", "other", "bugs",
                  "test-data", "proto-test", "work", "tests"],
        holdUntilCrawlEnd: false
    },
    plugins: [
        vue(),
        electron([
            {
                // Main-Process entry file of the Electron App.
                entry: "src/electron/main.ts",
            },
            {
                entry: "src/electron/preload.ts",
                onstart(options): void {
                    // Notify the Renderer-Process to reload the page when the Preload-Scripts build
                    // is complete, instead of restarting the entire Electron App.
                    options.reload();
                },
            },
        ]),
        renderer(),
        vueDevTools(),
        cleanPlugin({
            targetFiles: ["dist", "dist-electron"]
        })
    ],
    build: {
        assetsInlineLimit: 8096,
        reportCompressedSize: false,
        emptyOutDir: true,
        chunkSizeWarningLimit: 850,
        rolldownOptions: {
            output: {
                manualChunks(id: string) {
                    if(id.includes('node_modules')) {
                        if(id.includes('vue') ||
                           id.includes('pinia') ||
                           id.includes('vuetify') ||
                           id.includes('@mdi/js')) return 'vue';

                        if(id.includes('three')) return 'three';

                        if(id.includes('troika-three-text')) return 'troika';
                    }
                    // return undefined to let Rollup decide for app code
                }
            }
        }
    },
});

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions