2022-12-10 12:14:48 +03:00
|
|
|
import preact from '@preact/preset-vite';
|
2022-12-15 09:42:34 +03:00
|
|
|
import { execSync } from 'child_process';
|
2022-12-13 15:42:09 +03:00
|
|
|
import { resolve } from 'path';
|
2022-12-15 06:47:11 +03:00
|
|
|
import { defineConfig, splitVendorChunkPlugin } from 'vite';
|
2022-12-19 09:51:56 +03:00
|
|
|
import { VitePWA } from 'vite-plugin-pwa';
|
|
|
|
|
|
|
|
const { VITE_CLIENT_NAME: CLIENT_NAME, NODE_ENV } = process.env;
|
2022-12-10 12:14:48 +03:00
|
|
|
|
2022-12-15 09:42:34 +03:00
|
|
|
const commitHash = execSync('git rev-parse --short HEAD').toString().trim();
|
|
|
|
|
2022-12-10 12:14:48 +03:00
|
|
|
// https://vitejs.dev/config/
|
|
|
|
export default defineConfig({
|
2022-12-19 09:51:56 +03:00
|
|
|
mode: NODE_ENV,
|
2022-12-15 09:42:34 +03:00
|
|
|
define: {
|
|
|
|
__BUILD_TIME__: JSON.stringify(Date.now()),
|
|
|
|
__COMMIT_HASH__: JSON.stringify(commitHash),
|
|
|
|
},
|
2022-12-19 09:51:56 +03:00
|
|
|
plugins: [
|
|
|
|
preact(),
|
|
|
|
splitVendorChunkPlugin(),
|
|
|
|
VitePWA({
|
|
|
|
manifest: {
|
|
|
|
name: CLIENT_NAME,
|
|
|
|
short_name: CLIENT_NAME,
|
|
|
|
description: 'Minimalistic opinionated Mastodon web client',
|
|
|
|
theme_color: '#ffffff',
|
|
|
|
icons: [
|
|
|
|
{
|
|
|
|
src: 'logo-192.png',
|
|
|
|
sizes: '192x192',
|
|
|
|
type: 'image/png',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
src: 'logo-512.png',
|
|
|
|
sizes: '512x512',
|
|
|
|
type: 'image/png',
|
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
|
|
|
strategies: 'injectManifest',
|
|
|
|
injectRegister: 'inline',
|
|
|
|
injectManifest: {
|
|
|
|
// Prevent "Unable to find a place to inject the manifest" error
|
|
|
|
injectionPoint: undefined,
|
|
|
|
},
|
|
|
|
devOptions: {
|
|
|
|
enabled: NODE_ENV === 'development',
|
|
|
|
type: 'module',
|
|
|
|
},
|
|
|
|
}),
|
|
|
|
],
|
2022-12-13 15:42:09 +03:00
|
|
|
build: {
|
2022-12-15 06:47:11 +03:00
|
|
|
sourcemap: true,
|
2022-12-13 15:42:09 +03:00
|
|
|
rollupOptions: {
|
|
|
|
input: {
|
|
|
|
main: resolve(__dirname, 'index.html'),
|
|
|
|
compose: resolve(__dirname, 'compose/index.html'),
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2022-12-10 12:14:48 +03:00
|
|
|
});
|