Created
August 27, 2021 04:01
-
-
Save mattsplat/d03f1ccd1d417490bcca2d13705e340e to your computer and use it in GitHub Desktop.
Lazy Load Vue3 Laravel
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require('./bootstrap'); | |
import {createApp} from "vue"; | |
import {registerComponents} from './components'; | |
const app = createApp({}); | |
registerComponents(app) | |
app.mount('#app') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import {defineAsyncComponent} from "vue"; | |
const lazyLoadComponents = { | |
OrganizationGrid: defineAsyncComponent(() => import(/* webpackChunkName:"OrganizationGrid" */ "./components/Organization/OrganizationGrid")), | |
DspBoolean: defineAsyncComponent(() => import(/* webpackChunkName:"DspBoolean" */ "./components/Base/DspBoolean")), | |
DspDate: defineAsyncComponent(() => import(/* webpackChunkName:"DspDate" */ "./components/Base/DspDate")), | |
} | |
export const lazyLoadComponents = (app) => { | |
for (let name in (lazyLoadComponents)) { | |
app.component(name, lazyLoadComponents[name]); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment