alkem-io / client-web

Default web frontend, enabling browsing the Alkemio platform - so the hosted Challenges and communities collaborating around those Challenges.
https://alkem.io
European Union Public License 1.2
16 stars 6 forks source link

Timebox: Reduce the bundle size #6594

Open ccanos opened 4 months ago

ccanos commented 4 months ago

Description

As a an Alkemio user I want a reduced bundle so pages load faster

Acceptance criteria

Hints:

Additional Context

After extracting Excalidraw from the bundle, (#6593) maybe other things can also be extracted.

From another issue:

Areas that will be affected

Client. The whole application.

Timeboxed to: one day

techsmyth commented 4 months ago

From Svetlo in #4367:

  1. Links https://rizkicitra.dev/blog/improving-performance-in-react https://rizkicitra.dev/blog/improving-performance-in-react#using-vite-js https://www.npmjs.com/package/rollup-plugin-visualizer
  2. Some code pushed in client-4637

    // vite.config.ts
    import { chunkSplitPlugin } from 'vite-plugin-chunk-split';
    //...
    plugins: [
    chunkSplitPlugin({
    strategy: 'unbundle',
    customChunk: args => {
      // files into pages directory is export in single files
      let { file, id, moduleId, root } = args;
    
    },
    customSplitting: {
      'react-vendor': ['react', 'react-dom'],
      'core': [/src\/core/],
      'dev': [/src\/dev/],
      'domain': [/src\/domain/],
      'main': [/src\/main/],
      // 'core-ui': [/src\/core\/ui/],
      // 'core-apollo': [/src\/core\/apollo/],
      // 'core-auth': [/src\/core\/auth/],
      // 'core-routing': [/src\/core\/routing/],
      // 'core-utils': [/src\/core\/utils/],
    }
    })
    ]
  3. Found out that the index.html adds some <link rel="modulepreload" crossorigin href="xxx"> and preloads all the resources when the page loads.