diff --git a/CLAUDE.md b/CLAUDE.md index d4c6d96..b8aa831 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -78,6 +78,8 @@ None of these were discoverable locally — there's no npm here (see "Local-only - **`package.json` needs `"type": "module"`.** `vite.config.js` uses `import`/`export` syntax and `@nextcloud/vite-config` is ESM-only; without `"type": "module"`, Node treats `.js` as CommonJS and `vite build` fails trying to `require()` an ESM-only package. - **A `tsconfig.json` must exist at the repo root, even though this project has no TypeScript source.** `@nextcloud/vite-config`'s `index.js` barrel statically re-exports `createLibConfig` from `libConfig.js`, which imports `vite-plugin-dts` at module scope — that import chain runs just from importing `createAppConfig`, regardless of whether `createLibConfig` is ever called. The minimal `tsconfig.json` in this repo exists to give that a config to resolve, not because we write TypeScript. On its own this did **not** fix the crash below — see the next bullet. - **`typescript` must be an explicit devDependency.** `vite-plugin-dts` (pulled in transitively by the bullet above, version `^4.5.4` as of `@nextcloud/vite-config@2.5.4`) peer-depends on `typescript: "*"` but doesn't install it itself. Without a `typescript` devDependency in our own `package.json`, nothing provides that package, and `vite-plugin-dts`'s `@volar/typescript` integration crashes at module-load time — before `vite.config.js`'s own code or `tsconfig.json` are ever consulted — with `Cannot read properties of undefined (reading 'useCaseSensitiveFileNames')` (`proxyCreateProgram`). This is the actual fix; `tsconfig.json` existing is necessary but not sufficient. Keep `typescript` reasonably close to the version `@nextcloud/vite-config` itself develops against (currently `^5.9.3`) if you bump either. +- **`createAppConfig` prefixes every entry name with the app id**, so the entry `personal-settings` is emitted as `js/workflow_deck_automation-personal-settings.mjs` and `css/workflow_deck_automation-personal-settings.css`. `Util::addScript()`/`addStyle()` take that *full on-disk basename* (minus extension), not the bare entry name — `lib/Settings/Personal.php` therefore passes `Application::APP_ID . '-personal-settings'`. Getting this wrong produces a **silently blank settings page**: the template's empty mount `
` renders fine, and the only symptom is `Could not find resource workflow_deck_automation/js/….js to load` (`jsresourceloader`) plus a matching `Could not find resource file "/apps/workflow_deck_automation/css/….css"` in `nextcloud.log`. If you rename the entry in `vite.config.js`, rename it in `Personal.php` too. +- **The bulk of the CSS lives in a hashed `*.chunk.css`**, loaded at runtime by the `.mjs` bundle (`cssCodeSplit: true`). The `css/workflow_deck_automation-personal-settings.css` that `addStyle()` points at is the ~100-byte stub produced by `createEmptyCSSEntryPoints: true`. A near-empty entry CSS file is expected — don't "fix" it by turning off code splitting. ## Local-only notes diff --git a/lib/Settings/Personal.php b/lib/Settings/Personal.php index 81bba5c..e25bae4 100644 --- a/lib/Settings/Personal.php +++ b/lib/Settings/Personal.php @@ -11,8 +11,9 @@ use OCP\Util; class Personal implements ISettings { public function getForm(): TemplateResponse { - Util::addScript(Application::APP_ID, 'workflow-deck-automation-personal-settings'); - Util::addStyle(Application::APP_ID, 'workflow-deck-automation-personal-settings'); + // The bundle names carry the app-id prefix that @nextcloud/vite-config adds. + Util::addScript(Application::APP_ID, Application::APP_ID . '-personal-settings'); + Util::addStyle(Application::APP_ID, Application::APP_ID . '-personal-settings'); return new TemplateResponse(Application::APP_ID, 'settings/personal', [], ''); } diff --git a/vite.config.js b/vite.config.js index ec51b7c..541fb3e 100644 --- a/vite.config.js +++ b/vite.config.js @@ -1,7 +1,9 @@ import { createAppConfig } from '@nextcloud/vite-config' export default createAppConfig({ - 'workflow-deck-automation-personal-settings': 'src/main.js', + // @nextcloud/vite-config prefixes every entry with the app id, so this + // emits js/workflow_deck_automation-personal-settings.mjs + 'personal-settings': 'src/main.js', }, { createEmptyCSSEntryPoints: true, config: {