2022-12-20 16:17:51 +01:00
|
|
|
import { defineConfig } from 'vite';
|
|
|
|
import react from '@vitejs/plugin-react';
|
|
|
|
import { wasm } from '@rollup/plugin-wasm';
|
|
|
|
import { viteStaticCopy } from 'vite-plugin-static-copy';
|
2024-05-12 06:06:53 +02:00
|
|
|
import { vanillaExtractPlugin } from '@vanilla-extract/vite-plugin';
|
2023-01-30 05:20:53 +01:00
|
|
|
import { NodeGlobalsPolyfillPlugin } from '@esbuild-plugins/node-globals-polyfill';
|
|
|
|
import inject from '@rollup/plugin-inject';
|
2024-05-12 06:06:53 +02:00
|
|
|
import topLevelAwait from 'vite-plugin-top-level-await';
|
2024-09-07 15:45:55 +02:00
|
|
|
import { VitePWA } from 'vite-plugin-pwa';
|
2024-05-12 06:06:53 +02:00
|
|
|
import buildConfig from './build.config';
|
2022-12-20 16:17:51 +01:00
|
|
|
|
|
|
|
const copyFiles = {
|
|
|
|
targets: [
|
|
|
|
{
|
|
|
|
src: 'node_modules/@matrix-org/olm/olm.wasm',
|
|
|
|
dest: '',
|
|
|
|
},
|
2023-10-06 04:44:06 +02:00
|
|
|
{
|
2024-05-12 08:14:34 +02:00
|
|
|
src: 'node_modules/pdfjs-dist/build/pdf.worker.min.mjs',
|
2023-10-06 04:44:06 +02:00
|
|
|
dest: '',
|
2024-05-12 08:14:34 +02:00
|
|
|
rename: 'pdf.worker.min.js',
|
2023-10-06 04:44:06 +02:00
|
|
|
},
|
2022-12-20 16:17:51 +01:00
|
|
|
{
|
2024-01-21 13:50:56 +01:00
|
|
|
src: 'netlify.toml',
|
2022-12-20 16:17:51 +01:00
|
|
|
dest: '',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
src: 'config.json',
|
|
|
|
dest: '',
|
|
|
|
},
|
2023-08-03 06:23:28 +02:00
|
|
|
{
|
|
|
|
src: 'public/manifest.json',
|
|
|
|
dest: '',
|
|
|
|
},
|
2022-12-20 16:17:51 +01:00
|
|
|
{
|
|
|
|
src: 'public/res/android',
|
|
|
|
dest: 'public/',
|
2023-08-03 06:23:28 +02:00
|
|
|
},
|
2024-08-14 15:29:34 +02:00
|
|
|
{
|
|
|
|
src: 'public/locales',
|
|
|
|
dest: 'public/',
|
|
|
|
},
|
2022-12-20 16:17:51 +01:00
|
|
|
],
|
2024-05-12 06:06:53 +02:00
|
|
|
};
|
2022-12-20 16:17:51 +01:00
|
|
|
|
|
|
|
export default defineConfig({
|
|
|
|
appType: 'spa',
|
|
|
|
publicDir: false,
|
2024-01-21 13:50:56 +01:00
|
|
|
base: buildConfig.base,
|
2022-12-20 16:17:51 +01:00
|
|
|
server: {
|
|
|
|
port: 8080,
|
|
|
|
host: true,
|
2024-05-31 16:19:46 +02:00
|
|
|
proxy: {
|
2024-09-07 15:45:55 +02:00
|
|
|
'^\\/.*?\\/olm\\.wasm$': {
|
2024-05-31 16:19:46 +02:00
|
|
|
target: 'http://localhost:8080',
|
2024-09-07 15:45:55 +02:00
|
|
|
rewrite: () => '/olm.wasm',
|
|
|
|
},
|
|
|
|
},
|
2022-12-20 16:17:51 +01:00
|
|
|
},
|
|
|
|
plugins: [
|
2024-05-12 06:06:53 +02:00
|
|
|
topLevelAwait({
|
|
|
|
// The export name of top-level await promise for each chunk module
|
|
|
|
promiseExportName: '__tla',
|
|
|
|
// The function to generate import names of top-level await promise in each chunk module
|
|
|
|
promiseImportName: (i) => `__tla_${i}`,
|
|
|
|
}),
|
2022-12-20 16:17:51 +01:00
|
|
|
viteStaticCopy(copyFiles),
|
2023-06-12 13:15:23 +02:00
|
|
|
vanillaExtractPlugin(),
|
2022-12-20 16:17:51 +01:00
|
|
|
wasm(),
|
|
|
|
react(),
|
2024-09-07 15:45:55 +02:00
|
|
|
VitePWA({
|
|
|
|
srcDir: 'src',
|
|
|
|
filename: 'sw.ts',
|
|
|
|
strategies: 'injectManifest',
|
|
|
|
injectRegister: false,
|
|
|
|
manifest: false,
|
|
|
|
injectManifest: {
|
|
|
|
injectionPoint: undefined,
|
|
|
|
},
|
2024-09-09 10:45:20 +02:00
|
|
|
devOptions: {
|
|
|
|
enabled: true,
|
|
|
|
type: 'module'
|
|
|
|
}
|
2024-09-07 15:45:55 +02:00
|
|
|
}),
|
2022-12-20 16:17:51 +01:00
|
|
|
],
|
2023-01-30 05:20:53 +01:00
|
|
|
optimizeDeps: {
|
|
|
|
esbuildOptions: {
|
2024-05-12 06:06:53 +02:00
|
|
|
define: {
|
|
|
|
global: 'globalThis',
|
|
|
|
},
|
|
|
|
plugins: [
|
|
|
|
// Enable esbuild polyfill plugins
|
|
|
|
NodeGlobalsPolyfillPlugin({
|
|
|
|
process: false,
|
|
|
|
buffer: true,
|
|
|
|
}),
|
|
|
|
],
|
|
|
|
},
|
2023-01-30 05:20:53 +01:00
|
|
|
},
|
2022-12-20 16:17:51 +01:00
|
|
|
build: {
|
|
|
|
outDir: 'dist',
|
|
|
|
sourcemap: true,
|
|
|
|
copyPublicDir: false,
|
2023-01-30 05:20:53 +01:00
|
|
|
rollupOptions: {
|
2024-05-12 06:06:53 +02:00
|
|
|
plugins: [inject({ Buffer: ['buffer', 'Buffer'] })],
|
|
|
|
},
|
2022-12-20 16:17:51 +01:00
|
|
|
},
|
|
|
|
});
|