Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OV-43: Add PWA #47

Merged
merged 9 commits into from
Aug 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,6 @@ build
.DS_Store
.env
.idea

# PWA
dev-dist/
5 changes: 4 additions & 1 deletion frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,16 @@
"devDependencies": {
"@types/react": "18.3.3",
"@types/react-dom": "18.3.0",
"@vite-pwa/assets-generator": "0.2.4",
"@vitejs/plugin-react": "4.3.1",
"autoprefixer": "10.4.20",
"eslint-plugin-jsx-a11y": "6.9.0",
"eslint-plugin-react": "7.35.0",
"eslint-plugin-react-hooks": "4.6.2",
"postcss": "8.4.41",
"vite": "5.4.0"
"vite": "5.4.0",
"vite-plugin-pwa": "0.20.1",
"workbox-core": "7.1.0"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why we need this package?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From what I understand, the Vite PWA plugin will use the Workbox Core library to interact with and build the service worker.
https://vite-pwa-org.netlify.app/workbox/

},
"dependencies": {
"@chakra-ui/icons": "2.1.1",
Expand Down
12 changes: 12 additions & 0 deletions frontend/pwa-assets.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import {
defineConfig,
minimal2023Preset as preset,
} from '@vite-pwa/assets-generator/config';

export default defineConfig({
headLinkOptions: {
preset: '2023',
},
preset,
images: ['public/vite.svg'],
});
36 changes: 35 additions & 1 deletion frontend/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { fileURLToPath } from 'node:url';

import reactPlugin from '@vitejs/plugin-react';
import { type ConfigEnv, defineConfig, loadEnv } from 'vite';
import { VitePWA } from 'vite-plugin-pwa';

const config = ({ mode }: ConfigEnv): ReturnType<typeof defineConfig> => {
const {
Expand All @@ -14,7 +15,40 @@ const config = ({ mode }: ConfigEnv): ReturnType<typeof defineConfig> => {
build: {
outDir: 'build',
},
plugins: [reactPlugin()],
plugins: [
reactPlugin(),
VitePWA({
registerType: 'autoUpdate',
injectRegister: false,

pwaAssets: {
disabled: false,
config: true,
},

manifest: {
name: 'OutreachVids',
short_name: 'OV',
description:
'Create personalized sales videos using generated video content and AI-generated avatars.',
theme_color: '#eb5500',
background_color: '#0a0049',
},

workbox: {
globPatterns: ['**/*.{js,css,html,svg,png,ico}'],
cleanupOutdatedCaches: true,
clientsClaim: true,
},

devOptions: {
enabled: true,
navigateFallback: 'index.html',
suppressWarnings: true,
type: 'module',
},
}),
],
server: {
port: Number(VITE_APP_DEVELOPMENT_PORT),
proxy: {
Expand Down
Loading
Loading