> For the complete documentation index, see [llms.txt](https://pwa.spomky-labs.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://pwa.spomky-labs.com/deployment.md).

# Deployment

As this bundle leverages Asset Mapper, the resources are served using this great component.

In the `dev` environment, the resources are automatically handled and returned by your Symfony app.

For the `prod` environment, before deploy, you should run:

```shell
symfony console asset-map:compile
```

This command also compiles the PWA files. If you disabled that integration with `asset_compiler: false`, run `pwa:compile` as well:

```shell
symfony console pwa:compile
```

## Applications Served From A Sub-Directory

If your application is not served from the root of its domain, e.g. `https://example.com/my-project/`, all the URLs the bundle generates — favicons, manifest, service worker, Workbox scripts, precached assets — are prefixed with the base path, exactly like the URLs returned by the `asset()` Twig function.

When a page is rendered, the base path is read from the current request and there is nothing to configure.

Compilation is different: it happens on the command line, where no request exists. The base path is then taken from the router request context, so `default_uri` must be set:

{% code title="/config/packages/routing.yaml" lineNumbers="true" %}

```yaml
framework:
    router:
        default_uri: 'https://example.com/my-project'
```

{% endcode %}

Without it, the compiled files point at the root of the domain and return a 404. The most visible symptom is the service worker failing to start, because its `importScripts()` calls resolve to `/workbox/workbox-sw.js` instead of `/my-project/workbox/workbox-sw.js`.

Should you need a base path for the assets different from the one of the router, override the `asset.request_context.base_path` parameter instead:

{% code title="/config/services.yaml" lineNumbers="true" %}

```yaml
parameters:
    asset.request_context.base_path: '/my-project'
```

{% endcode %}

{% hint style="warning" %}
The values you write yourself are never rewritten. The service worker [`scope`](/the-service-worker/configuration.md), the `href` of a [resource hint](/performance/resource-hints.md) and the [offline fallback](/the-service-worker/workbox/offline-fallback.md) page are used as-is, so include the base path in them when your application needs one.
{% endhint %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://pwa.spomky-labs.com/deployment.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
