86 lines
1.7 KiB
JavaScript
86 lines
1.7 KiB
JavaScript
import { defineConfig } from 'vite';
|
|
import react from '@vitejs/plugin-react';
|
|
import { wasm } from '@rollup/plugin-wasm';
|
|
import { viteStaticCopy } from 'vite-plugin-static-copy';
|
|
import { vanillaExtractPlugin } from "@vanilla-extract/vite-plugin";
|
|
import { NodeGlobalsPolyfillPlugin } from '@esbuild-plugins/node-globals-polyfill';
|
|
import inject from '@rollup/plugin-inject';
|
|
import { svgLoader } from './viteSvgLoader';
|
|
|
|
const copyFiles = {
|
|
targets: [
|
|
{
|
|
src: 'node_modules/@matrix-org/olm/olm.wasm',
|
|
dest: '',
|
|
},
|
|
{
|
|
src: 'node_modules/pdfjs-dist/build/pdf.worker.min.js',
|
|
dest: '',
|
|
},
|
|
{
|
|
src: '_redirects',
|
|
dest: '',
|
|
},
|
|
{
|
|
src: 'config.json',
|
|
dest: '',
|
|
},
|
|
{
|
|
src: 'public/manifest.json',
|
|
dest: '',
|
|
},
|
|
{
|
|
src: 'public/res/android',
|
|
dest: 'public/',
|
|
},
|
|
{
|
|
src: 'public/mx-uc.css',
|
|
dest: '',
|
|
},
|
|
{
|
|
src: 'twemoji/assets/svg/*',
|
|
dest: 'twemoji/',
|
|
},
|
|
],
|
|
}
|
|
|
|
export default defineConfig({
|
|
appType: 'spa',
|
|
publicDir: false,
|
|
base: "",
|
|
server: {
|
|
port: 8080,
|
|
host: true,
|
|
},
|
|
plugins: [
|
|
viteStaticCopy(copyFiles),
|
|
vanillaExtractPlugin(),
|
|
svgLoader(),
|
|
wasm(),
|
|
react(),
|
|
],
|
|
optimizeDeps: {
|
|
esbuildOptions: {
|
|
define: {
|
|
global: 'globalThis'
|
|
},
|
|
plugins: [
|
|
// Enable esbuild polyfill plugins
|
|
NodeGlobalsPolyfillPlugin({
|
|
process: false,
|
|
buffer: true,
|
|
}),
|
|
]
|
|
}
|
|
},
|
|
build: {
|
|
outDir: 'dist',
|
|
sourcemap: true,
|
|
copyPublicDir: false,
|
|
rollupOptions: {
|
|
plugins: [
|
|
inject({ Buffer: ['buffer', 'Buffer'] })
|
|
]
|
|
}
|
|
},
|
|
});
|