2022-12-21 00:17:51 +09: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-06-12 20:15:23 +09:00
|
|
|
import { vanillaExtractPlugin } from "@vanilla-extract/vite-plugin";
|
2023-01-30 13:20:53 +09:00
|
|
|
import { NodeGlobalsPolyfillPlugin } from '@esbuild-plugins/node-globals-polyfill';
|
|
|
|
import inject from '@rollup/plugin-inject';
|
2024-01-21 21:50:56 +09:00
|
|
|
import { svgLoader } from './viteSvgLoader'
|
|
|
|
import buildConfig from "./build.config"
|
2022-12-21 00:17:51 +09:00
|
|
|
|
|
|
|
const copyFiles = {
|
|
|
|
targets: [
|
|
|
|
{
|
|
|
|
src: 'node_modules/@matrix-org/olm/olm.wasm',
|
|
|
|
dest: '',
|
|
|
|
},
|
2023-10-06 11:44:06 +09:00
|
|
|
{
|
|
|
|
src: 'node_modules/pdfjs-dist/build/pdf.worker.min.js',
|
|
|
|
dest: '',
|
|
|
|
},
|
2022-12-21 00:17:51 +09:00
|
|
|
{
|
2024-01-21 21:50:56 +09:00
|
|
|
src: 'netlify.toml',
|
2022-12-21 00:17:51 +09:00
|
|
|
dest: '',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
src: 'config.json',
|
|
|
|
dest: '',
|
|
|
|
},
|
2023-08-03 13:23:28 +09:00
|
|
|
{
|
|
|
|
src: 'public/manifest.json',
|
|
|
|
dest: '',
|
|
|
|
},
|
2022-12-21 00:17:51 +09:00
|
|
|
{
|
|
|
|
src: 'public/res/android',
|
|
|
|
dest: 'public/',
|
2023-08-03 13:23:28 +09:00
|
|
|
},
|
2022-12-21 00:17:51 +09:00
|
|
|
],
|
|
|
|
}
|
|
|
|
|
|
|
|
export default defineConfig({
|
|
|
|
appType: 'spa',
|
|
|
|
publicDir: false,
|
2024-01-21 21:50:56 +09:00
|
|
|
base: buildConfig.base,
|
2022-12-21 00:17:51 +09:00
|
|
|
server: {
|
|
|
|
port: 8080,
|
|
|
|
host: true,
|
|
|
|
},
|
|
|
|
plugins: [
|
|
|
|
viteStaticCopy(copyFiles),
|
2023-06-12 20:15:23 +09:00
|
|
|
vanillaExtractPlugin(),
|
2023-01-15 13:22:58 +09:00
|
|
|
svgLoader(),
|
2022-12-21 00:17:51 +09:00
|
|
|
wasm(),
|
|
|
|
react(),
|
|
|
|
],
|
2023-01-30 13:20:53 +09:00
|
|
|
optimizeDeps: {
|
|
|
|
esbuildOptions: {
|
|
|
|
define: {
|
|
|
|
global: 'globalThis'
|
|
|
|
},
|
|
|
|
plugins: [
|
|
|
|
// Enable esbuild polyfill plugins
|
|
|
|
NodeGlobalsPolyfillPlugin({
|
|
|
|
process: false,
|
|
|
|
buffer: true,
|
|
|
|
}),
|
|
|
|
]
|
|
|
|
}
|
|
|
|
},
|
2022-12-21 00:17:51 +09:00
|
|
|
build: {
|
|
|
|
outDir: 'dist',
|
|
|
|
sourcemap: true,
|
|
|
|
copyPublicDir: false,
|
2023-01-30 13:20:53 +09:00
|
|
|
rollupOptions: {
|
|
|
|
plugins: [
|
|
|
|
inject({ Buffer: ['buffer', 'Buffer'] })
|
|
|
|
]
|
|
|
|
}
|
2022-12-21 00:17:51 +09:00
|
|
|
},
|
|
|
|
});
|