LuanRoger / electron-shadcn

:electron: Electron Forge with shadcn-ui (Vite + Typescript)
MIT License
164 stars 27 forks source link

Add vite-plugin-compression for asset compression in production builds #53

Open karthic-keyan opened 2 months ago

karthic-keyan commented 2 months ago

Summary

To improve the performance of our Electron-based project, we should add the vite-plugin-compression plugin to compress static assets (JavaScript, CSS, etc.) during production builds.

This will help reduce the size of the assets sent to clients, improving load times and overall performance.

Tasks

  1. Install vite-plugin-compression as a dev dependency:

    npm install vite-plugin-compression --save-dev
  2. Configure the plugin in vite.config.ts:

    import viteCompression from 'vite-plugin-compression';
    
    export default defineConfig({
      plugins: [
        viteCompression({
          algorithm: 'brotliCompress',  // You can choose 'gzip' as well
          ext: '.br',                   // or '.gz' for gzip
          threshold: 10240,             // Compress files larger than 10kb
          deleteOriginFile: false       // Keep original uncompressed files
        })
      ]
    });
  3. Update the README.md to include information about vite-plugin-compression and how it's used to compress assets.

  4. Test the build process by running:

    npm run build
  5. Ensure that compressed files (.br or .gz) are created in the dist folder.

Acceptance Criteria

codinginbarn commented 1 month ago

I do not find the "vite.config.ts". Only see:

image

Rookie Electron user and interested in Vite :)