Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import { defineConfig, loadEnv } from 'vite';
- import react from '@vitejs/plugin-react';
- import svgr from 'vite-plugin-svgr';
- import { VitePWA } from 'vite-plugin-pwa';
- import compression from 'vite-plugin-compression2';
- import * as path from 'path';
- // https://vitejs.dev/config/
- export default defineConfig(({ command, mode }) => {
- // Load env file based on `mode` in the current working directory.
- // Set the third parameter to '' to load all env regardless of the `VITE_` prefix.
- const env = loadEnv(mode, process.cwd(), '');
- return {
- plugins: [
- svgr(),
- react(),
- compression(),
- VitePWA({
- injectRegister: null,
- registerType: 'autoUpdate',
- devOptions: {
- enabled: env.VITE_ENV === 'local',
- },
- /*includeAssets: [
- 'favicon.ico',
- 'apple-touch-icon.png',
- 'mask-icon.svg',
- ],*/
- // strategies: 'injectManifest',
- srcDir: 'src',
- filename: 'sw.js',
- manifest: {
- name: 'Safer',
- short_name: 'Safer',
- description: 'Safer - invitation only social media',
- theme_color: '#ffffff',
- icons: [
- {
- src: 'pwa-192x192.png',
- sizes: '192x192',
- type: 'image/png',
- },
- {
- src: 'pwa-512x512.png',
- sizes: '512x512',
- type: 'image/png',
- },
- {
- src: 'maskable-icon-512x512.png',
- sizes: '192x192',
- type: 'image/png',
- purpose: 'any maskable',
- },
- ],
- },
- // add this to cache all the imports
- workbox: {
- globPatterns: ['**/*'],
- importScripts: [''],
- swDest: 'dist/sw.js',
- },
- // add this to cache all the
- // static assets in the public folder
- includeAssets: ['**/*'],
- }),
- ],
- server: {
- port: 3000,
- open: '/',
- },
- resolve: {
- alias: {
- '@': path.resolve(__dirname, './src'),
- },
- },
- };
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement