Skip to content

Commit

Permalink
Fixed production and started pwa support
Browse files Browse the repository at this point in the history
  • Loading branch information
GuilhermeF03 committed Jun 28, 2024
1 parent eda1fb9 commit 73ae016
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 21 deletions.
1 change: 1 addition & 0 deletions code/client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@
"sass": "^1.77.0",
"typescript": "^5.5.2",
"vite": "^5.2.11",
"vite-plugin-pwa": "^0.20.0",
"vite-tsconfig-paths": "^4.3.2",
"vitest": "^1.6.0"
}
Expand Down
2 changes: 1 addition & 1 deletion code/client/public/robots.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# https://www.robotstxt.org/robotstxt.html
User-agent: *
Disallow:
Allow: /
22 changes: 22 additions & 0 deletions code/client/src/pwa/manifest-config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import {ManifestOptions} from "vite-plugin-pwa";

const manifestConfig : Partial<ManifestOptions> = {
name: 'NoteSpace',
short_name: 'NoteSpace',
description: 'A multiplatform note management and sharing app',
theme_color: '#ffffff',
icons: [
{
src: '/assets/icon.png',
sizes: '192x192',
type: 'image/png',
},
{
src: '/assets/icon.png',
sizes: '512x512',
type: 'image/png',
},
],
}

export default manifestConfig;
11 changes: 11 additions & 0 deletions code/client/src/pwa/pwa-config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import {VitePWAOptions} from "vite-plugin-pwa";
//import manifestConfig from "./manifest-config";

const pwaConfig : Partial<VitePWAOptions> = {
registerType: 'autoUpdate',
//manifest: manifestConfig,
//devOptions: {
// enabled: true,
//}
}
export default pwaConfig;
27 changes: 7 additions & 20 deletions code/client/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import { defineConfig } from 'vite';
import react from '@vitejs/plugin-react';
import tsconfigPaths from 'vite-tsconfig-paths';
import { config } from 'dotenv';
import {VitePWA} from "vite-plugin-pwa";
import pwaConfig from "./src/pwa/pwa-config";

// Load environment variables from .env file
config();
Expand All @@ -14,26 +16,11 @@ export default defineConfig({
server: {
port: Number.parseInt(process.env.VITE_PORT) || 5173,
},
plugins: [tsconfigPaths(), react()],
build: {
// Enable sourcemaps if needed
// sourcemap: true,
rollupOptions: {
output: {
manualChunks: (id: string) => {
if (id.includes('node_modules')) {
if (id.includes('react')) return 'react';
if (id.includes('slate')) return 'slate';
return 'vendor';
}
if (id.includes('src')) return 'app';
},
entryFileNames: 'assets/[name].js',
chunkFileNames: 'assets/[name].js',
assetFileNames: 'assets/[name].[ext]',
},
},
},
plugins: [
tsconfigPaths(),
react(),
VitePWA(pwaConfig)
],
test: {
globals: true,
alias: {
Expand Down

0 comments on commit 73ae016

Please sign in to comment.