perf: Lazy load dashboard components

Signed-off-by: Julius Härtl <jus@bitgrid.net>
This commit is contained in:
Julius Härtl 2023-02-08 17:33:39 +01:00
parent c4cd472dd3
commit 06bf0e1d71
2 changed files with 16 additions and 5 deletions

View File

@ -1,10 +1,11 @@
import Vue from 'vue'
import Dashboard from './components/Dashboard.vue'
Vue.mixin({ methods: { t, n } })
__webpack_nonce__ = btoa(OC.requestToken) // eslint-disable-line
__webpack_public_path__ = OC.linkTo('notes', 'js/') // eslint-disable-line
document.addEventListener('DOMContentLoaded', () => {
OCA.Dashboard.register('notes', (el) => {
OCA.Dashboard.register('notes', async (el) => {
const { default: Vue } = await import(/* webpackChunkName: "dashboard-lazy" */'vue')
const { default: Dashboard } = await import(/* webpackChunkName: "dashboard-lazy" */'./components/Dashboard.vue')
Vue.mixin({ methods: { t, n } })
const View = Vue.extend(Dashboard)
new View().$mount(el)
})

View File

@ -3,4 +3,14 @@ const path = require('path')
webpackConfig.entry.dashboard = path.join(__dirname, 'src', 'dashboard.js')
webpackConfig.optimization = {
splitChunks: {
cacheGroups: {
defaultVendors: {
name: 'commons',
}
},
},
}
module.exports = webpackConfig