import { defineConfig } from "vite"; import vue from "@vitejs/plugin-vue"; import vueJsx from "@vitejs/plugin-vue-jsx"; import vitePluginVuetify from "vite-plugin-vuetify"; 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) => { console.log("rESOLVE", name); if (name.match(/^V[A-Z]/) && !name.includes("VEmojiPicker")) return { name, from: './node_modules/vuetify/components' } }, } } // 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({ template: { compilerOptions: { comments: false } } }), vueJsx(), vitePluginVuetify(), // 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: "vue", replacement: fileURLToPath(new URL("./node_modules/vue/dist/vue.esm-bundler.js", 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", // }, // }, }));