keanu-weblite/vite.config.mjs
N-Pex ec992bb14d Fix vite build release version
Also, make sure "export" strings are not removed (rename to "room_export") and import quotes in the QuoteView correctly.
2025-05-19 10:23:50 +02:00

109 lines
3 KiB
JavaScript

import { defineConfig } from "vite";
import vue from "@vitejs/plugin-vue2";
import { fileURLToPath, URL } from "node:url";
import Components from "unplugin-vue-components/vite";
import { viteStaticCopy } from 'vite-plugin-static-copy';
import nodePolyfills from 'rollup-plugin-polyfill-node';
import { resolve } from "path";
import commonjs from '@rollup/plugin-commonjs';
function VuetifyResolver() {
return {
type: 'component',
resolve: (name) => {
if (name.match(/^V[A-Z]/) && !name.includes("VEmojiPicker"))
return { name, from: 'vuetify/lib' }
},
}
}
// https://vitejs.dev/config/
export default defineConfig(({mode}) => ({
plugins: [
// commonjs({
// include: /node_modules/,
// requireReturnsDefault: 'auto', // <---- this solves default issue
// }),
// commonjs({
// exclude: ["*vuex-persist*", "*deepmerge*"]
// }),
vue(),
Components({
resolvers: [VuetifyResolver()],
}),
viteStaticCopy({
targets: [
{
src: "src/assets/config.json",
dest: ''
},
{
src: "node_modules/@matrix-org/olm/olm.wasm",
dest: ''
},
{
src: 'node_modules/@matrix-org/matrix-sdk-crypto-wasm/pkg/matrix_sdk_crypto_wasm_bg.wasm',
dest: mode == "development" ? '/node_modules/.vite/deps/pkg' : ''
}
]
}),
//nodePolyfills(),
],
resolve: {
extensions: ['.vue','.mjs', '.js', '.ts', '.jsx', '.tsx', '.json','.wasm'],
alias: [
{ find: "@", replacement: fileURLToPath(new URL("./src", import.meta.url)) },
{ find: "~@", replacement: fileURLToPath(new URL("./src", import.meta.url)) },
{ find: "~vuetify", replacement: fileURLToPath(new URL("./node_modules/vuetify", import.meta.url)) },
],
},
define: {
//global: "window",
//module: {},
Lame: "window.Lame",
Presets: "window.Presets",
GainAnalysis: "window.GainAnalysis",
QuantizePVT: "window.QuantizePVT",
Quantize: "window.Quantize",
Takehiro: "window.Takehiro",
Reservoir: "window.Reservoir",
MPEGMode: "window.MPEGMode",
BitStream: "window.BitStream",
},
build: {
commonjsOptions: { transformMixedEsModules: true } // Change
}
// optimizeDeps: {
// include: ["deepmerge", "vuex-persist"],
// },
// optimizeDeps: {
// include: [
// "vuex-persist", "vue-sanitize"
// ],
// esbuildOptions:{
// plugins:[
// commonjs()
// ]
// }
// },
// build: {
// commonjsOptions: {
// include: [/node_modules/],
// requireReturnsDefault: true,
// exclude: ["vuex-persist"]
// }
// },
// rollupOptions: {
// //Here, we are externalizing Vue to prevent it to be bundled
// //with our library
// external: ["vue"],
// //Add this so the UMD build will recognize the global variables
// //of externalized dependencies
// output: {
// globals: {
// vue: "Vue",
// },
// exports: "named",
// },
// },
}));