• Services

Static assets

Static assets are things like CSS and Javascript files, or images. By default these aren't accessible by the browser, unless you define them as static assets in your module.json file.

Marking a directory as static

Consider the following directory structure for the example below:

├── module.json
└── web/
    ├── index.php
    └── static/
        ├── scripts.js
        └── styles.css

Here, we want to make the subdirectory web/static available as static assets.

To do so, we add the key webOptions.staticAssets to our module.json file:

  "slug": "my-module",


    "staticPaths": [

The file scripts.js is now available at the URL /my-module/web/static/scripts.js.


In the above example, we used the wildcard character * to denote that every file in the directory web/static should be marked as a static asset.

Important to note is that, if there would be a directoryweb/static/image, files in that directory wouldn't be marked as static assets with the code above, since the wildcard only applies to a single directory level.

Recursive inclusion

It is possible to use two wildecard characters after each other at the end of the path string to denote recursive inclusion:

web/static/** would match not only web/static/scripts.js, but also web/static/images/icons/star.png.