-
Notifications
You must be signed in to change notification settings - Fork 1
Webserver Required To Serve Generated Docs
Michael Leahy edited this page Sep 24, 2024
·
2 revisions
The "default modern theme" (DMT) requires generated docs to be served by a web server. This is due to the DMT using ES Modules loading which requires
a web server. When trying to open a page with a file:// URL you will receive a CORS error. There are several easy options described below on how you can serve docs or access them locally through an IDE web server and / or how to easily start your own web server to view docs locally:
- Github Pages is very easy to setup to serve
docsand thesetupsection forPageslooks like this:
- IDEs like WebStorm / VSCode have automatic web servers to open docs directly from the IDE. You might need the LiveServer plugin for VSCode. I use WebStorm and the docs will just open from the IDE and work out of the box.
- There are plenty of various server packages for Node available on NPM. The static page server that I find easiest to use is sirv, but sirv-cli makes it easy. You can use npx to invoke
sirv-cliand create the following NPM script to serve the generated docs assuming they are in adocsfolder. You can then open the docs from your browser to the local static web server.
{
"scripts": {
"sirv": "npx sirv-cli docs --host"
}
}