home chevron_right
Generating Your Site

Generating Your Sitelink

Build for productionlink

To generate your static site for deployment, run the following command:

npm run build

You'll see an output similar to this (default scaffold uses Laravel Mix + webpack):

Laravel Mix v6.0.49

✔ Compiled Successfully in 0.09s
Assets (truncated):
- /js/main.js (112 KiB)
- /js/turbo.js (208 KiB)
- /css/main.css (26 KiB)
- /img/icon-arrow.svg (221 bytes)
- /img/icon_and_text_logo.svg (3.07 KiB)
- /img/logo.svg (429 bytes)
- /img/magnifying-glass.svg (979 bytes)
- /fonts/... (Inter variable + static variants)

webpack compiled successfully

Your complete static site will be generated in the /build_production directory, ready for deployment.

As the output shows, Mix/webpack compiles, minifies, and versions your assets. This process includes bundling, where Mix combines multiple JavaScript and CSS files into optimized ones. Large font files are included once under /fonts/ and reused across pages.

The bundled asset paths are referenced in your generated HTML files, like this:

<link rel="stylesheet" href="/assets/build/css/main.css?id=xyz" />
<script defer src="/assets/build/js/main.js?id=abc"></script>

Assets that do not require compilation (e.g., images, fonts) are simply copied from your source/assets directory to the equivalent assets path within /build_production. For example, an image located at source/assets/img/1.png will be copied to /build_production/assets/img/1.png.

This means the paths you use in your original files for these assets remain unchanged:

<img src="/assets/img/1.png" />

Environmentslink

Often you might want to use different site variables in your development and production environments. For example, in production you might want to render your Google Analytics tracking snippet, but not include it in development so you don�t skew your results.

Docara makes this simple by allowing you to create additional config.php files for your different environments.

Say your base config.php file looks like this:

<?php

return [
    'debug' => true,
    'company' => 'Simai',
];

You can override the staging variable in your production environment by creating a new file called config.production.php:

<?php

return [
    'debug' => false,
];

This file is merged on top of config.php, so you only need to specify the variables that you are changing.

Note: Variables from environment-specific config files are not merged recursively; only the top-level keys are considered for merging. For collections, you can override this behavior by setting merge_collection_configs to true in your main config.php file. This is particularly useful if you use collection filtering to disable some collection items, such as draft blog posts, in particular environments.

Build for a specific environmentlink

To build files for a specific environment, set the NODE_ENV variable when running the build command:

NODE_ENV=staging npm run build

This will output the site to a new folder named build_staging, leaving other build directories (build_local, build_production) untouched.

If you�re not using Mix/Vite to compile assets, you can run Docara's build command directly and pass the environment name:

vendor/bin/docara build staging