Advertisement
ahashans

Untitled

Feb 5th, 2024
1,018
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import { defineConfig, loadEnv } from 'vite';
  2. import react from '@vitejs/plugin-react';
  3. import svgr from 'vite-plugin-svgr';
  4. import { VitePWA } from 'vite-plugin-pwa';
  5. import compression from 'vite-plugin-compression2';
  6. import * as path from 'path';
  7.  
  8. // https://vitejs.dev/config/
  9. export default defineConfig(({ command, mode }) => {
  10.     // Load env file based on `mode` in the current working directory.
  11.     // Set the third parameter to '' to load all env regardless of the `VITE_` prefix.
  12.     const env = loadEnv(mode, process.cwd(), '');
  13.     return {
  14.         plugins: [
  15.             svgr(),
  16.             react(),
  17.             compression(),
  18.             VitePWA({
  19.                 injectRegister: null,
  20.                 registerType: 'autoUpdate',
  21.                 devOptions: {
  22.                     enabled: env.VITE_ENV === 'local',
  23.                 },
  24.                 /*includeAssets: [
  25.                     'favicon.ico',
  26.                     'apple-touch-icon.png',
  27.                     'mask-icon.svg',
  28.                 ],*/
  29.                 // strategies: 'injectManifest',
  30.                 srcDir: 'src',
  31.                 filename: 'sw.js',
  32.                 manifest: {
  33.                     name: 'Safer',
  34.                     short_name: 'Safer',
  35.                     description: 'Safer - invitation only social media',
  36.                     theme_color: '#ffffff',
  37.                     icons: [
  38.                         {
  39.                             src: 'pwa-192x192.png',
  40.                             sizes: '192x192',
  41.                             type: 'image/png',
  42.                         },
  43.                         {
  44.                             src: 'pwa-512x512.png',
  45.                             sizes: '512x512',
  46.                             type: 'image/png',
  47.                         },
  48.                         {
  49.                             src: 'maskable-icon-512x512.png',
  50.                             sizes: '192x192',
  51.                             type: 'image/png',
  52.                             purpose: 'any maskable',
  53.                         },
  54.                     ],
  55.                 },
  56.                 // add this to cache all the imports
  57.                 workbox: {
  58.                     globPatterns: ['**/*'],
  59.                     importScripts: [''],
  60.                     swDest: 'dist/sw.js',
  61.                 },
  62.                 // add this to cache all the
  63.                 // static assets in the public folder
  64.                 includeAssets: ['**/*'],
  65.             }),
  66.         ],
  67.         server: {
  68.             port: 3000,
  69.             open: '/',
  70.         },
  71.         resolve: {
  72.             alias: {
  73.                 '@': path.resolve(__dirname, './src'),
  74.             },
  75.         },
  76.     };
  77. });
  78.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement