2022-01-14 13:50:58 -05:00
|
|
|
import macrosPlugin from "@insertish/vite-plugin-babel-macros";
|
2021-07-31 12:58:26 -04:00
|
|
|
import replace from "@rollup/plugin-replace";
|
|
|
|
import { readFileSync } from "fs";
|
|
|
|
import { resolve } from "path";
|
|
|
|
import { defineConfig } from "vite";
|
|
|
|
import { VitePWA } from "vite-plugin-pwa";
|
|
|
|
|
|
|
|
import preact from "@preact/preset-vite";
|
2021-06-22 08:47:47 -04:00
|
|
|
|
|
|
|
function getGitRevision() {
|
2021-07-31 12:58:26 -04:00
|
|
|
try {
|
|
|
|
const rev = readFileSync(".git/HEAD").toString().trim();
|
|
|
|
if (rev.indexOf(":") === -1) {
|
|
|
|
return rev;
|
|
|
|
}
|
2021-10-23 11:42:04 -04:00
|
|
|
|
|
|
|
return readFileSync(`.git/${rev.substring(5)}`)
|
|
|
|
.toString()
|
|
|
|
.trim();
|
2021-07-31 12:58:26 -04:00
|
|
|
} catch (err) {
|
|
|
|
console.error("Failed to get Git revision.");
|
|
|
|
return "?";
|
2021-06-22 08:47:47 -04:00
|
|
|
}
|
|
|
|
}
|
2021-06-18 07:05:01 -04:00
|
|
|
|
2021-06-22 14:45:44 -04:00
|
|
|
function getGitBranch() {
|
2021-07-31 12:58:26 -04:00
|
|
|
try {
|
|
|
|
const rev = readFileSync(".git/HEAD").toString().trim();
|
|
|
|
if (rev.indexOf(":") === -1) {
|
|
|
|
return "DETACHED";
|
|
|
|
}
|
2021-10-23 11:42:04 -04:00
|
|
|
|
|
|
|
return rev.split("/").pop();
|
2021-07-31 12:58:26 -04:00
|
|
|
} catch (err) {
|
|
|
|
console.error("Failed to get Git branch.");
|
|
|
|
return "?";
|
2021-06-22 14:45:44 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-06-22 14:34:52 -04:00
|
|
|
function getVersion() {
|
2021-07-31 12:58:26 -04:00
|
|
|
return readFileSync("VERSION").toString();
|
2021-06-22 14:34:52 -04:00
|
|
|
}
|
|
|
|
|
2021-06-18 07:05:01 -04:00
|
|
|
export default defineConfig({
|
2021-07-31 12:58:26 -04:00
|
|
|
plugins: [
|
|
|
|
preact(),
|
2022-01-14 13:50:58 -05:00
|
|
|
macrosPlugin(),
|
2021-07-31 12:58:26 -04:00
|
|
|
VitePWA({
|
|
|
|
srcDir: "src",
|
|
|
|
filename: "sw.ts",
|
|
|
|
strategies: "injectManifest",
|
|
|
|
manifest: {
|
2021-10-23 11:42:04 -04:00
|
|
|
name: "Revolt",
|
2021-07-31 12:58:26 -04:00
|
|
|
short_name: "Revolt",
|
2021-10-23 11:42:04 -04:00
|
|
|
description: "User-first, privacy-focused chat platform.",
|
2022-01-20 05:03:47 -05:00
|
|
|
categories: ["communication", "chat", "messaging"],
|
2021-07-31 12:58:26 -04:00
|
|
|
start_url: "/",
|
|
|
|
orientation: "portrait",
|
2022-01-20 05:03:47 -05:00
|
|
|
/*display_override: ["window-controls-overlay"],*/
|
2021-07-31 12:58:26 -04:00
|
|
|
display: "standalone",
|
|
|
|
background_color: "#101823",
|
|
|
|
theme_color: "#101823",
|
|
|
|
icons: [
|
|
|
|
{
|
2021-10-23 11:42:04 -04:00
|
|
|
src: `/assets/icons/android-chrome-192x192.png`,
|
2021-07-31 12:58:26 -04:00
|
|
|
type: "image/png",
|
|
|
|
sizes: "192x192",
|
|
|
|
},
|
|
|
|
{
|
2021-10-23 11:42:04 -04:00
|
|
|
src: `/assets/icons/android-chrome-512x512.png`,
|
2021-07-31 12:58:26 -04:00
|
|
|
type: "image/png",
|
|
|
|
sizes: "512x512",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
src: `/assets/icons/monochrome.svg`,
|
|
|
|
type: "image/svg+xml",
|
|
|
|
sizes: "48x48 72x72 96x96 128x128 256x256",
|
|
|
|
purpose: "monochrome",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
src: `/assets/icons/masking-512x512.png`,
|
|
|
|
type: "image/png",
|
|
|
|
sizes: "512x512",
|
|
|
|
purpose: "maskable",
|
|
|
|
},
|
|
|
|
],
|
2022-01-20 05:03:47 -05:00
|
|
|
//TODO: add shortcuts relating to your last opened direct messages
|
|
|
|
/*shortcuts: [
|
|
|
|
{
|
|
|
|
"name": "Open Play Later",
|
|
|
|
"short_name": "Play Later",
|
|
|
|
"description": "View the list of podcasts you saved for later",
|
|
|
|
"url": "/play-later?utm_source=homescreen",
|
|
|
|
"icons": [{ "src": "/icons/play-later.png", "sizes": "192x192" }]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"name": "View Subscriptions",
|
|
|
|
"short_name": "Subscriptions",
|
|
|
|
"description": "View the list of podcasts you listen to",
|
|
|
|
"url": "/subscriptions?utm_source=homescreen",
|
|
|
|
"icons": [{ "src": "/icons/subscriptions.png", "sizes": "192x192" }]
|
|
|
|
}
|
|
|
|
]*/
|
2021-07-07 18:30:30 -04:00
|
|
|
},
|
2021-07-31 12:58:26 -04:00
|
|
|
}),
|
|
|
|
replace({
|
|
|
|
__GIT_REVISION__: getGitRevision(),
|
|
|
|
__GIT_BRANCH__: getGitBranch(),
|
|
|
|
__APP_VERSION__: getVersion(),
|
|
|
|
preventAssignment: true,
|
2022-01-14 13:50:58 -05:00
|
|
|
}) as any,
|
2021-07-31 12:58:26 -04:00
|
|
|
],
|
|
|
|
build: {
|
|
|
|
sourcemap: true,
|
|
|
|
rollupOptions: {
|
|
|
|
input: {
|
|
|
|
main: resolve(__dirname, "index.html"),
|
|
|
|
ui: resolve(__dirname, "ui/index.html"),
|
2021-07-07 18:30:30 -04:00
|
|
|
},
|
2021-07-31 12:58:26 -04:00
|
|
|
},
|
|
|
|
},
|
2021-12-23 07:21:00 -05:00
|
|
|
optimizeDeps: {
|
|
|
|
exclude: ["revolt.js"],
|
|
|
|
},
|
2021-07-31 12:58:26 -04:00
|
|
|
});
|