For AI agents: the complete documentation index is available at /vue-vrm/ja/llms.txt, the full documentation bundle is available at /vue-vrm/ja/llms-full.txt, and this page is available as Markdown at /vue-vrm/ja/guide/bundling.md.
  • 日本語
  • バンドルのヒント

    three.jsとthree-vrmは比較的大きなライブラリです。別のチャンクに分けると、メインのバンドルが小さくなり、ブラウザーも個別にキャッシュできます。

    Vite

    // vite.config.ts
    import { defineConfig } from 'vite';
    
    export default defineConfig({
      build: {
        rollupOptions: {
          output: {
            manualChunks(id) {
              if (id.includes('/node_modules/three/')) return 'three';
              if (id.includes('/node_modules/@pixiv/')) return 'three-vrm';
            }
          }
        }
      }
    });

    Rsbuild

    // rsbuild.config.ts
    import { defineConfig } from '@rsbuild/core';
    
    export default defineConfig({
      splitChunks: {
        cacheGroups: {
          three: {
            test: /node_modules[\\/](three|@pixiv)[\\/]/,
            name: 'three',
            chunks: 'all'
          }
        }
      }
    });

    遅延読み込み

    最初の画面でアバターが不要な場合は、コンポーネントを非同期で読み込みます。

    import { defineAsyncComponent } from 'vue';
    
    const VrmCanvas = defineAsyncComponent(async () => (await import('vue-vrm')).VrmCanvas);