revite/vite.config.ts

67 lines
1.6 KiB
TypeScript
Raw Normal View History

2021-06-18 10:35:35 -04:00
import { resolve } from 'path'
2021-06-22 08:47:47 -04:00
import { readFileSync } from 'fs'
2021-06-18 07:05:01 -04:00
import { defineConfig } from 'vite'
import preact from '@preact/preset-vite'
2021-06-18 14:25:33 -04:00
import { VitePWA } from 'vite-plugin-pwa'
2021-06-22 08:47:47 -04:00
import replace from '@rollup/plugin-replace'
function getGitRevision() {
try {
const rev = readFileSync('.git/HEAD').toString().trim();
if (rev.indexOf(':') === -1) {
return rev;
} else {
return readFileSync('.git/' + rev.substring(5)).toString().trim();
}
} catch (err) {
console.error('Failed to get Git revision.');
return '?';
}
}
2021-06-18 07:05:01 -04:00
export default defineConfig({
2021-06-18 14:25:33 -04:00
plugins: [
preact(),
VitePWA({
2021-06-22 09:22:35 -04:00
srcDir: 'src',
filename: 'sw.ts',
strategies: 'injectManifest',
2021-06-18 14:25:33 -04:00
manifest: {
2021-06-22 09:22:35 -04:00
name: "REVOLT",
short_name: "REVOLT",
2021-06-18 14:25:33 -04:00
description: "User-first, privacy-focused chat platform.",
categories: ["messaging"],
start_url: "/",
display: "standalone",
orientation: "portrait",
background_color: "#101823",
icons: [
{
"src": "/assets/icons/android-chrome-192x192.png",
"type": "image/png",
"sizes": "192x192"
},
{
"src": "/assets/icons/android-chrome-512x512.png",
"type": "image/png",
"sizes": "512x512"
}
]
2021-06-22 09:22:35 -04:00
}
2021-06-22 08:47:47 -04:00
}),
replace({
__GIT_REVISION__: getGitRevision(),
preventAssignment: true
2021-06-18 14:25:33 -04:00
})
],
2021-06-18 10:35:35 -04:00
build: {
2021-06-19 07:34:53 -04:00
sourcemap: true,
2021-06-18 10:35:35 -04:00
rollupOptions: {
input: {
main: resolve(__dirname, 'index.html'),
ui: resolve(__dirname, 'ui/index.html')
}
}
}
2021-06-18 07:05:01 -04:00
})