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

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,
],
],
],
]

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
x-mediastringThe media type of the asset.Nall

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