cinny/vite.config.js

73 lines
1.4 KiB
JavaScript
Raw Normal View History

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-29 04:54:03 +00:00
import { NodeGlobalsPolyfillPlugin } from '@esbuild-plugins/node-globals-polyfill';
import rollupNodePolyFill from 'rollup-plugin-node-polyfills'
import { svgLoader } from './viteSvgLoader';
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,
server: {
port: 8080,
host: true,
},
2023-01-29 12:42:52 +00:00
define: {
global: "globalThis",
},
plugins: [
viteStaticCopy(copyFiles),
svgLoader(),
wasm(),
react(),
],
2023-01-29 04:54:03 +00:00
optimizeDeps: {
esbuildOptions: {
define: {
global: 'globalThis'
},
plugins: [
// Enable esbuild polyfill plugins
NodeGlobalsPolyfillPlugin({
process: false,
buffer: true,
}),
]
}
2023-01-29 06:32:26 +00:00
},
build: {
outDir: 'dist',
sourcemap: true,
copyPublicDir: false,
2023-01-29 04:54:03 +00:00
rollupOptions: {
plugins: [
// Enable rollup polyfills plugin
// used during production bundling
2023-01-29 12:42:52 +00:00
rollupNodePolyFill(),
2023-01-29 04:54:03 +00:00
]
}
},
});