Skip to content

Commit 4f6c35d

Browse files
committed
perf: Lazy load dashboard components
Signed-off-by: Julius Härtl <jus@bitgrid.net>
1 parent c4cd472 commit 4f6c35d

2 files changed

Lines changed: 16 additions & 5 deletions

File tree

src/dashboard.js

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1-
import Vue from 'vue'
2-
import Dashboard from './components/Dashboard.vue'
3-
4-
Vue.mixin({ methods: { t, n } })
1+
__webpack_nonce__ = btoa(OC.requestToken) // eslint-disable-line
2+
__webpack_public_path__ = OC.linkTo('notes', 'js/') // eslint-disable-line
53

64
document.addEventListener('DOMContentLoaded', () => {
7-
OCA.Dashboard.register('notes', (el) => {
5+
OCA.Dashboard.register('notes', async (el) => {
6+
const { default: Vue } = await import(/* webpackChunkName: "dashboard-lazy" */'vue')
7+
const { default: Dashboard } = await import(/* webpackChunkName: "dashboard-lazy" */'./components/Dashboard.vue')
8+
Vue.mixin({ methods: { t, n } })
89
const View = Vue.extend(Dashboard)
910
new View().$mount(el)
1011
})

webpack.config.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,14 @@ const path = require('path')
33

44
webpackConfig.entry.dashboard = path.join(__dirname, 'src', 'dashboard.js')
55

6+
webpackConfig.optimization = {
7+
splitChunks: {
8+
cacheGroups: {
9+
defaultVendors: {
10+
name: 'commons',
11+
}
12+
},
13+
},
14+
}
15+
616
module.exports = webpackConfig

0 commit comments

Comments
 (0)