Tag Archives: Vue3

[Solved] Some chunks are bigger warning on vite packaging

Solution:

import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'

export default defineConfig({
	plugins: [vue()],
	build: {
		rollupOptions: {
			output: {
				//Solve Warning: Some chunks are larger
				manualChunks(id) {
					if (id.includes('node_modules')) {
						return id.toString().split('node_modules/')[1].split('/')[0].toString();
					}
				}
			}
		}
	}
})

Method of getting app. Config. Globalproperties. X directly from vue3

Suppose we define a global method in main. JS

//main.js

 app.config.globalProperties.$hello = name => {
      console.log('hello ' + name)
 }

Call this method in other pages.

//other.js

import { getCurrentInstance } from "vue";
const { appContext } = getCurrentInstance();

const callHello = ()=>{
 appContext.config.globalProperties.$hello('jay');
}

callHello()
//'hello jay'