Matthew Raymer
2 weeks ago
68 changed files with 9313 additions and 9131 deletions
File diff suppressed because it is too large
@ -0,0 +1,69 @@ |
|||||
|
import * as path from "path"; |
||||
|
import { promises as fs } from "fs"; |
||||
|
|
||||
|
export async function loadAppConfig() { |
||||
|
const packageJson = await loadPackageJson(); |
||||
|
const appName = process.env.TIME_SAFARI_APP_TITLE || packageJson.name; |
||||
|
|
||||
|
return { |
||||
|
pwaConfig: { |
||||
|
registerType: "autoUpdate", |
||||
|
strategies: "injectManifest", |
||||
|
srcDir: ".", |
||||
|
filename: "sw_scripts-combined.js", |
||||
|
manifest: { |
||||
|
name: appName, |
||||
|
short_name: appName, |
||||
|
icons: [ |
||||
|
{ |
||||
|
src: "./img/icons/android-chrome-192x192.png", |
||||
|
sizes: "192x192", |
||||
|
type: "image/png", |
||||
|
}, |
||||
|
{ |
||||
|
src: "./img/icons/android-chrome-512x512.png", |
||||
|
sizes: "512x512", |
||||
|
type: "image/png", |
||||
|
}, |
||||
|
{ |
||||
|
src: "./img/icons/android-chrome-maskable-192x192.png", |
||||
|
sizes: "192x192", |
||||
|
type: "image/png", |
||||
|
purpose: "maskable", |
||||
|
}, |
||||
|
{ |
||||
|
src: "./img/icons/android-chrome-maskable-512x512.png", |
||||
|
sizes: "512x512", |
||||
|
type: "image/png", |
||||
|
purpose: "maskable", |
||||
|
}, |
||||
|
], |
||||
|
share_target: { |
||||
|
action: "/share-target", |
||||
|
method: "POST", |
||||
|
enctype: "multipart/form-data", |
||||
|
params: { |
||||
|
files: [ |
||||
|
{ |
||||
|
name: "photo", |
||||
|
accept: ["image/*"], |
||||
|
}, |
||||
|
], |
||||
|
}, |
||||
|
}, |
||||
|
}, |
||||
|
}, |
||||
|
aliasConfig: { |
||||
|
"@": path.resolve(__dirname, "./src"), |
||||
|
buffer: path.resolve(__dirname, "node_modules", "buffer"), |
||||
|
"dexie-export-import/dist/import": |
||||
|
"dexie-export-import/dist/import/index.js", |
||||
|
}, |
||||
|
}; |
||||
|
} |
||||
|
|
||||
|
async function loadPackageJson() { |
||||
|
const packageJsonPath = path.resolve(__dirname, "package.json"); |
||||
|
const packageJsonData = await fs.readFile(packageJsonPath, "utf-8"); |
||||
|
return JSON.parse(packageJsonData); |
||||
|
} |
@ -1,53 +1,26 @@ |
|||||
import * as path from 'path'; |
import { defineConfig } from "vite"; |
||||
import { defineConfig } from 'vite'; |
import { VitePWA } from "vite-plugin-pwa"; |
||||
import { VitePWA } from 'vite-plugin-pwa'; |
import vue from "@vitejs/plugin-vue"; |
||||
import vue from '@vitejs/plugin-vue'; |
import dotenv from "dotenv"; |
||||
|
import { loadAppConfig } from "./vite.config.utils"; |
||||
|
|
||||
|
// Load environment variables from .env file
|
||||
|
dotenv.config(); |
||||
|
|
||||
|
// Load application configuration
|
||||
|
const appConfig = loadAppConfig(); |
||||
|
|
||||
// https://vitejs.dev/config/
|
|
||||
export default defineConfig({ |
export default defineConfig({ |
||||
server: { |
server: { |
||||
port: 8080 |
port: process.env.VITE_PORT || 8080, |
||||
}, |
}, |
||||
plugins: [ |
plugins: [ |
||||
vue(), |
vue(), |
||||
VitePWA({ |
VitePWA({ |
||||
registerType: 'autoUpdate', |
...appConfig.pwaConfig, |
||||
strategies: 'injectManifest', |
|
||||
srcDir: '.', |
|
||||
filename: 'sw_scripts-combined.js', |
|
||||
manifest: { |
|
||||
// This is used for the app name. It doesn't include a space, because iOS complains if I recall correctly.
|
|
||||
// There is a name with spaces in the constants/app.js file for use internally.
|
|
||||
name: process.env.TIME_SAFARI_APP_TITLE || require('./package.json').name, |
|
||||
short_name: process.env.TIME_SAFARI_APP_TITLE || require('./package.json').name, |
|
||||
// 192x192 and 512x512 are important for Chrome to show that it's installable
|
|
||||
"icons":[ |
|
||||
{"src":"./img/icons/android-chrome-192x192.png","sizes":"192x192","type":"image/png"}, |
|
||||
{"src":"./img/icons/android-chrome-512x512.png","sizes":"512x512","type":"image/png"}, |
|
||||
{"src":"./img/icons/android-chrome-maskable-192x192.png","sizes":"192x192","type":"image/png","purpose":"maskable"}, |
|
||||
{"src":"./img/icons/android-chrome-maskable-512x512.png","sizes":"512x512","type":"image/png","purpose":"maskable"} |
|
||||
], |
|
||||
share_target: { |
|
||||
action: '/share-target', |
|
||||
method: 'POST', |
|
||||
enctype: 'multipart/form-data', |
|
||||
params: { |
|
||||
files: [ |
|
||||
{ |
|
||||
name: 'photo', |
|
||||
accept: ['image/*'], |
|
||||
}, |
|
||||
], |
|
||||
}, |
|
||||
}, |
|
||||
}, |
|
||||
}), |
}), |
||||
], |
], |
||||
resolve: { |
resolve: { |
||||
alias: { |
alias: appConfig.aliasConfig, |
||||
'@': path.resolve(__dirname, './src'), |
|
||||
buffer: path.resolve(__dirname, 'node_modules', 'buffer'), |
|
||||
'dexie-export-import/dist/import': 'dexie-export-import/dist/import/index.js', |
|
||||
}, |
|
||||
}, |
}, |
||||
}); |
}); |
||||
|
@ -0,0 +1,69 @@ |
|||||
|
import * as path from "path"; |
||||
|
import { promises as fs } from "fs"; |
||||
|
|
||||
|
export async function loadAppConfig() { |
||||
|
const packageJson = await loadPackageJson(); |
||||
|
const appName = process.env.TIME_SAFARI_APP_TITLE || packageJson.name; |
||||
|
|
||||
|
return { |
||||
|
pwaConfig: { |
||||
|
registerType: "autoUpdate", |
||||
|
strategies: "injectManifest", |
||||
|
srcDir: ".", |
||||
|
filename: "sw_scripts-combined.js", |
||||
|
manifest: { |
||||
|
name: appName, |
||||
|
short_name: appName, |
||||
|
icons: [ |
||||
|
{ |
||||
|
src: "./img/icons/android-chrome-192x192.png", |
||||
|
sizes: "192x192", |
||||
|
type: "image/png", |
||||
|
}, |
||||
|
{ |
||||
|
src: "./img/icons/android-chrome-512x512.png", |
||||
|
sizes: "512x512", |
||||
|
type: "image/png", |
||||
|
}, |
||||
|
{ |
||||
|
src: "./img/icons/android-chrome-maskable-192x192.png", |
||||
|
sizes: "192x192", |
||||
|
type: "image/png", |
||||
|
purpose: "maskable", |
||||
|
}, |
||||
|
{ |
||||
|
src: "./img/icons/android-chrome-maskable-512x512.png", |
||||
|
sizes: "512x512", |
||||
|
type: "image/png", |
||||
|
purpose: "maskable", |
||||
|
}, |
||||
|
], |
||||
|
share_target: { |
||||
|
action: "/share-target", |
||||
|
method: "POST", |
||||
|
enctype: "multipart/form-data", |
||||
|
params: { |
||||
|
files: [ |
||||
|
{ |
||||
|
name: "photo", |
||||
|
accept: ["image/*"], |
||||
|
}, |
||||
|
], |
||||
|
}, |
||||
|
}, |
||||
|
}, |
||||
|
}, |
||||
|
aliasConfig: { |
||||
|
"@": path.resolve(__dirname, "./src"), |
||||
|
buffer: path.resolve(__dirname, "node_modules", "buffer"), |
||||
|
"dexie-export-import/dist/import": |
||||
|
"dexie-export-import/dist/import/index.js", |
||||
|
}, |
||||
|
}; |
||||
|
} |
||||
|
|
||||
|
async function loadPackageJson() { |
||||
|
const packageJsonPath = path.resolve(__dirname, "package.json"); |
||||
|
const packageJsonData = await fs.readFile(packageJsonPath, "utf-8"); |
||||
|
return JSON.parse(packageJsonData); |
||||
|
} |
Loading…
Reference in new issue