Skip to content

Commit

Permalink
fix: lazy load material icons in a single webpack chunk
Browse files Browse the repository at this point in the history
Signed-off-by: Elizabeth Danzberger <lizzy7128@tutanota.de>
  • Loading branch information
elzody committed Mar 13, 2024
1 parent ef67c61 commit d60477e
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/shared/components/ncIconPicker/NcIconPicker.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<template>
<NcPopover container="body" popup-role="dialog" :shown.sync="showIconPicker">
<NcPopover popup-role="dialog" :shown.sync="showIconPicker">
<template #trigger="slotProps">
<slot v-bind="slotProps" />
</template>
Expand Down
6 changes: 5 additions & 1 deletion src/shared/components/ncIconPicker/mixins/svgHelper.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,11 @@ export default {
return atob(strippedUri)
},
async getContextIcon(iconName) {
const { default: icon } = await import(`@mdi/svg/svg/${iconName}.svg`)
const { default: icon } = await import(
/* webpackChunkName: 'material-icons' */
/* webpackMode: 'lazy-once' */
`MaterialIcons/${iconName}.svg`
)

return this.uriToSvg(icon)
},
Expand Down
2 changes: 2 additions & 0 deletions src/shared/components/ncIconPicker/partials/Icon.vue
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ export default {
.icon-picker__icon {
border-radius: 15px !important;
padding: 8px !important;
width: 30px !important;
height: 30px !important;
margin: 2px !important;
border: 2px solid transparent !important;
Expand Down
2 changes: 1 addition & 1 deletion src/shared/components/ncIconPicker/partials/IconPicker.vue
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export default {
<style>
.icon-picker__icons {
max-width: 300px;
height: 500px;
max-height: 400px;
display: grid;
grid-template-columns: repeat(5, 1fr);
overflow-y: scroll;
Expand Down

0 comments on commit d60477e

Please sign in to comment.