Loader (cms-client.js), submodule-aware editor source path, build:watch
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
2e0bf1e88e
commit
cb7a7a1fab
8 files changed
+158
-7
No files matched your search
@@ -146,9 +146,18 @@ schema contract: [docs/styling.md](docs/styling.md).
|
||||
|
||||
## Deploying
|
||||
|
||||
Serve `dist/onpage-editor.js` at `/editor/onpage-editor.js` and let the existing loader do
|
||||
`if (document.cookie.includes('cms_preview=1')) import('/editor/onpage-editor.js')`. The bundle
|
||||
re-checks the cookie, so loading it for a visitor is a no-op.
|
||||
Part of the ecommerce monorepo as the `cms-onpageeditor` submodule. Each instance image (`tornberg`, `bygglagret`,
|
||||
`k6n`) and `Dockerfile.nginx` build it in an `onpage` stage (named context `onpageeditor`) and ship two files in `/editor/`:
|
||||
|
||||
- `cms-client.js` - the tiny loader (`src/loader-core.ts`, ~0.5 kB gz) that page templates already reference. It replaces the old
|
||||
hand-written `cms-client` in every instance. With the `cms_preview=1` cookie it imports `onpage-editor.js` from the same directory;
|
||||
otherwise it does nothing.
|
||||
- `onpage-editor.js` - the editor.
|
||||
|
||||
Entering/leaving edit mode: open any page with `?cms_preview=1` (sets the cookie, strips the param, reloads so the edge serves the
|
||||
live render) and `?cms_preview=0` to leave. Dev: `make dev` rebuilds both into the instance's `public/` (`npm run build:watch`,
|
||||
`CMS_ONPAGE_OUT`). The shared `@k6n/cms-editor` sources are found at `../backoffice/web/packages/cms-editor/src` (submodule layout),
|
||||
`../ecommerce/...` (standalone checkout), `.cms-editor/` (Docker) or `CMS_EDITOR_SRC`.
|
||||
|
||||
## Not done / next
|
||||
|
||||
|
||||
Reference in new issue
Block a user