2022-12-20 17:17:51 +02:00
|
|
|
import { defineConfig } from 'vite';
|
|
|
|
import react from '@vitejs/plugin-react';
|
|
|
|
import { wasm } from '@rollup/plugin-wasm';
|
|
|
|
import { viteStaticCopy } from 'vite-plugin-static-copy';
|
2023-01-30 06:20:53 +02:00
|
|
|
import { NodeGlobalsPolyfillPlugin } from '@esbuild-plugins/node-globals-polyfill';
|
|
|
|
import inject from '@rollup/plugin-inject';
|
2023-01-15 06:22:58 +02:00
|
|
|
import { svgLoader } from './viteSvgLoader';
|
2022-12-20 17:17:51 +02:00
|
|
|
|
|
|
|
const copyFiles = {
|
|
|
|
targets: [
|
|
|
|
{
|
|
|
|
src: 'node_modules/@matrix-org/olm/olm.wasm',
|
|
|
|
dest: '',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
src: '_redirects',
|
|
|
|
dest: '',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
src: 'config.json',
|
|
|
|
dest: '',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
src: 'public/res/android',
|
|
|
|
dest: 'public/',
|
|
|
|
}
|
|
|
|
],
|
|
|
|
}
|
|
|
|
|
|
|
|
export default defineConfig({
|
|
|
|
appType: 'spa',
|
|
|
|
publicDir: false,
|
2023-01-30 06:20:13 +02:00
|
|
|
base: "",
|
2022-12-20 17:17:51 +02:00
|
|
|
server: {
|
|
|
|
port: 8080,
|
|
|
|
host: true,
|
|
|
|
},
|
|
|
|
plugins: [
|
|
|
|
viteStaticCopy(copyFiles),
|
2023-01-15 06:22:58 +02:00
|
|
|
svgLoader(),
|
2022-12-20 17:17:51 +02:00
|
|
|
wasm(),
|
|
|
|
react(),
|
|
|
|
],
|
2023-01-30 06:20:53 +02:00
|
|
|
optimizeDeps: {
|
|
|
|
esbuildOptions: {
|
|
|
|
define: {
|
|
|
|
global: 'globalThis'
|
|
|
|
},
|
|
|
|
plugins: [
|
|
|
|
// Enable esbuild polyfill plugins
|
|
|
|
NodeGlobalsPolyfillPlugin({
|
|
|
|
process: false,
|
|
|
|
buffer: true,
|
|
|
|
}),
|
|
|
|
]
|
|
|
|
}
|
|
|
|
},
|
2022-12-20 17:17:51 +02:00
|
|
|
build: {
|
|
|
|
outDir: 'dist',
|
|
|
|
sourcemap: true,
|
|
|
|
copyPublicDir: false,
|
2023-01-30 06:20:53 +02:00
|
|
|
rollupOptions: {
|
|
|
|
plugins: [
|
|
|
|
inject({ Buffer: ['buffer', 'Buffer'] })
|
|
|
|
]
|
|
|
|
}
|
2022-12-20 17:17:51 +02:00
|
|
|
},
|
|
|
|
});
|