This repository was archived by the owner on May 29, 2026. It is now read-only.
feat: add example dashboard widget + splitChunks bundling pattern#26
Merged
Conversation
Wires the ConductionNL bundling pattern from ADR-004 (Build / bundling) into the template so apps cloned from this repo get a working dashboard widget out of the box and never trip the appName/devtool/duplicate-framework pitfalls that landed across opencatalogi/pipelinq/procest/docudesk. What is added: - webpack.config.js: optimization.splitChunks with stable-filename shared chunks for Vue + @nextcloud/vue + pinia + icons + @conduction/nextcloud-vue. Each entry-point keeps only entry-specific code; shared chunks load once. - lib/Dashboard/ExampleWidget.php: minimal IWidget. load() attaches shared chunks BEFORE the per-widget bundle (vendor → nc-vue → widget). Comments explain why and reference ADR-004. - src/exampleWidget.js: webpack entry that registers the Vue renderer via OCA.Dashboard.register. Hard-coded id matches Widget::getId() from PHP. - src/views/widgets/ExampleWidget.vue: minimal NcDashboardWidget that fetches /api/items via @nextcloud/axios with try/catch + graceful empty state. - AppInfo/Application.php: registerDashboardWidget(ExampleWidget::class). - README: 'Adding a dashboard widget' how-to listing the 5 registration points and pointing at ADR-004 for the full rationale. Apps that don't need a dashboard widget delete: - lib/Dashboard/ + src/exampleWidget.js + src/views/widgets/ - the registerDashboardWidget(...) line in Application.php - the exampleWidget entry in webpack.config.js The splitChunks block is harmless with only main + adminSettings entries (produces small shared chunks that two entries reuse) and starts paying off the moment a widget is added.
Contributor
Quality Report — ConductionNL/nextcloud-app-template @
|
| Check | PHP | Vue | Security | License | Tests |
|---|---|---|---|---|---|
| lint | ✅ | ||||
| phpcs | ✅ | ||||
| phpmd | ✅ | ||||
| psalm | ✅ | ||||
| phpstan | ✅ | ||||
| phpmetrics | ✅ | ||||
| eslint | ✅ | ||||
| stylelint | ✅ | ||||
| composer | ✅ | ✅ 100/100 | |||
| npm | ✅ | ✅ 215/215 | |||
| PHPUnit | ✅ | ||||
| Newman | ✅ | ||||
| Playwright | ⏭️ |
Coverage: 0% (0/3 statements)
Quality workflow — 2026-05-05 07:02 UTC
Download the full PDF report from the workflow artifacts.
Contributor
Author
|
Validated locally: Per-widget bundle is 190 KB (just widget code). Shared chunks load once across the page. Same pattern as pipelinq/procest/docudesk and matches ADR-004. |
This file contains hidden or 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
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Wires the ConductionNL bundling pattern from ADR-004 into the template so every new app cloned from this repo:
ExampleWidget)optimization.splitChunksconfig that prevents Vue +@nextcloud/vue+ pinia from being inlined into every entry-pointappName/appVersionDefinePluginlines already in placeTriggered by the recent mydash page-load investigation: every Conduction app with dashboard widgets had grown a duplicated-framework problem (228 MB of widget JS attached to
/apps/mydash/across opencatalogi + pipelinq + procest + docudesk + mydash). The fixes landed in those repos; this PR captures the pattern in the template so future apps don't repeat it.What changed
webpack.config.jsoptimization.splitChunkswith stable-filename-shared-vendor+-shared-nc-vuechunks; addsexampleWidgetentry-pointlib/Dashboard/ExampleWidget.phpIWidget.load()attaches the two shared chunks before the per-widget bundle (order: vendor → nc-vue → widget)src/exampleWidget.jsOCA.Dashboard.register. Hard-coded id matchesWidget::getId()src/views/widgets/ExampleWidget.vueNcDashboardWidgetwith axios fetch + graceful empty statelib/AppInfo/Application.php$context->registerDashboardWidget(ExampleWidget::class)README.mdHow an app cloning this template removes the widget
Apps without dashboard widgets delete:
lib/Dashboard/+src/exampleWidget.js+src/views/widgets/registerDashboardWidget(...)line inApplication.phpexampleWidgetentry inwebpack.config.jsThe
splitChunksblock is harmless with onlymain + adminSettingsentries (produces small shared chunks that two entries reuse) and starts paying off the moment a widget is added.Test plan
npm install && npm run buildsucceedsjs/containsapp-template-shared-vendor.js,app-template-shared-nc-vue.js,app-template-exampleWidget.js/apps/dashboard/(or mydash), confirm "Example widget" appears in the widget picker