Skip to content

Assets

config/assets.php

The assets configuration file contains all settings related to the theme assets.

The default config enqueues the site.js file on every page. This file is located in the assets/src/js directory.

For more advanced topics checkout Advanced/Vite.

Entrypoints are defined in config/entrypoints.json — this is the single source of truth shared with vite.config.ts. Adding an entry here is all that’s needed for Vite to pick it up.

config/entrypoints.json
{
"lumbermill": "assets/src/js/site.js",
"my-custom-js": "assets/src/js/my-custom.js"
}

To add WordPress-specific options for an entry (such as dependencies or admin-only loading), add it to the entrypoints array in config/assets.php. Entries without any options do not need an entry here.

config/assets.php
<?php
return [
'vite' => [
'entrypoints' => [
'my-custom-js' => [
'dependencies' => ['jquery'],
],
],
],
]

Some libraries need extra scripts to work properly, for example React. To make it easier to add these scripts, you can use the helpers array.

config/assets.php
<?php
return [
'vite' => [
'entrypoints' => [],
'helpers' => [
'react'
],
],
]
  • react

All options that can be used in the entrypoints array in config/assets.php.

OptionTypeDescriptionDefault
dependenciesarrayThe dependencies of the entry.[]
is_adminbooleanEnqueue only in the WordPress admin area.false
templatestringEnqueue only on pages using this page template.null

To enqueue an entry only in the WordPress admin area, set is_admin to true.

config/assets.php
<?php
return [
'vite' => [
'entrypoints' => [
'my-admin-js' => [
'is_admin' => true,
],
],
],
]

To enqueue an entry only on pages that use a specific page template, set template to the template path relative to the theme root. The entry is checked with is_page_template(), so it only applies to posts/pages with that template selected, not to archives or other routes.

config/assets.php
<?php
return [
'vite' => [
'entrypoints' => [
'my-agenda-js' => [
'template' => 'templates/agenda.php',
],
],
],
]

template is ignored when is_admin is true.

These settings allow you to add extra assets to the theme, without using Vite.

Note: These assets will not be processed by Vite, so minification/optimisations will not be applied.

Check out the example below to see how to add assets.

config/assets.php
<?php
return [
'assets' => [
'css' => [
'my-custom-style' => [
'path' => 'assets/src/scss/vendor/my-custom-style.css',
],
],
'js' => [
'my-custom-script' => [
'path' => 'assets/src/js/vendor/my-custom-script.js',
],
],
],
];

All options that can be used in the css and js arrays.

CSSJSOptionTypeDescriptionRequiredDefault
xxpathstringThe relative file location based on the theme root.Ynull
xxdependenciesarrayThe dependencies of the asset.N[]
xxversionstringThe version of the asset.Nnull
-xin_footerbooleanWhether or not to enqueue the asset in the footer.Nfalse
-xis_adminbooleanEnqueue only in the WordPress admin area.Nfalse
-xstrategystringLoading strategy: async or defer.Nnull
x-mediastringThe media type of the asset.Nall

Adds an async or defer attribute to the script tag. Omit it for a blocking script.

'js' => [
'instant-pages' => [
'path' => 'assets/dist/vendor/instant-page.js',
'in_footer' => true,
'strategy' => 'async',
],
],

WordPress only applies the attribute when the dependency graph allows it — a script with dependencies that are not themselves deferred, or one that other scripts depend on, silently falls back to blocking. Self-contained scripts are the safe candidates.

Is basically the same as the assets array, but is used for updating WordPress scripts.

These settings allow you to enable/disable certain optimisations.

The boilerplate comes with the following optimisations enabled:

  • Remove emoji styles