The Doh Export tool helps you create standalone HTML applications from your Doh projects. It combines all your application's code, styles, and assets into a single HTML file that can run without needing a server or internet connection.
This guide covers:
The export tool:
This capability is particularly valuable for:
doh export
This exports your application using the default pod.yaml
configuration.
doh export custom.pod.yaml
This uses a specific pod configuration for the export.
The export tool uses a special configuration section in your pod file:
export_load: ['module1', 'module2', 'styles.css', '^/local/script.js']
The export_load
property specifies which modules, scripts, and stylesheets should be included in the export. This follows the same format as any Doh load statement, supporting all the standard path notations and module references.
The export process follows these steps:
export_load
The export tool creates a virtual filesystem (VFS) accessible through DohOptions.VFS
that maps paths to data URLs:
DohOptions.VFS['/path/to/asset.png'] = "data:application/octet-stream;base64,..."
This allows your application to access embedded assets exactly as it would access files in a normal deployment.
The export tool leverages DohPath for resolving all file paths consistently. This ensures that:
/
, ^/
, ./
)When your application runs from the exported HTML, DohPath automatically works with the virtual filesystem to retrieve embedded assets:
// In your application code:
const imageUrl = DohPath('/assets/logo.png');
// During export, this becomes accessible via the VFS
The export tool fully integrates with the Doh Load System:
export_load
property as the entry point for your applicationYour application initializes with:
await Doh.load(export_load);
This ensures that your application bootstraps exactly as it would in a normal deployment.
<html>
<head>
<title>Doh.js</title>
<script type="importmap">
{"imports": {"module-name":"data:text/javascript;charset=utf-8,...","path":"data:..."}}
</script>
<script>/* Embedded script content */</script>
<style>/* Embedded CSS content */</style>
</head>
<body>
<script type="module">
globalThis.DohOptions = globalThis.DohOptions || {};
DohOptions.browser_pod = {...};
DohOptions.Packages = {...};
DohOptions.CorePatterns = {...};
DohOptions.PatternModule = {...};
DohOptions.PreloadedPackages = {...};
DohOptions.PreloadedScripts = [...];
DohOptions.PreloadedStylesheets = [...];
DohOptions.VFS = {};
DohOptions.VFS['/path/to/asset'] = "data:application/octet-stream;base64,...";
/* Embedded Doh runtime */
/* Embedded module content */
await Doh.load(["module1", "module2"]);
</script>
</body>
</html>
# pod.yaml
export_load: ['my-app-entrypoint', '/styles/main.css']
doh export
Share the file at /dist/export/doh.html
with users who need offline access.
To specify a custom output file, you can modify the export file path in your pod configuration:
export: {
output_file: "/custom/path/app.html"
}