Version 1 was a more complex version that supported multiple loading paths. It has since been rewritten to be much simpler and follow common patterns with less customizations (that were almost never used). Please only use version 2 going forward. You can find the version 1 documention here.
composer require vendi-advertising/vendi-asset-loader:^2
The asset loader relies almost completely on the following environment variables.
NOTE! This module does not actually perform logic related to .env
files, it is up to the theme to handle this if needed. Generally speaking, however, you can usually create a file named .env.local
with these values to override. Otherwise the system assumes true environment variables.
THEME_MODE
- Supported values:
prod
- Forces bothTHEME_CSS_MODE
andTHEME_JS_MODE
intostatic
modestage
- No difference currentlydev
(default) - No difference currently
- Supported values:
THEME_CSS_MODE
- Supported values:
dynamic
(default) - Loads CSS files from the/css/
relative to the path theme root following the glob pattern/css/[0-9][0-9][0-9]-*.css
static
- Loads CSS files as defined in the webpack encore entry file
- Usage notes:
- If
THEME_MODE
is set toprod
, this configured value is ignore and insteadstatic
is always used
- If
- Supported values:
THEME_JS_MODE
- Supported values:
dynamic
(default) - Loads JS files from the/js/
relative to the path theme root following the glob pattern/js/[0-9][0-9][0-9]-*.js
static
- Loads JS files as defined in the webpack encore entry file
- Usage notes:
- If
THEME_MODE
is set toprod
, this configured value is ignore and insteadstatic
is always used
- If
- Supported values:
THEME_WEBPACK_ENTRY_FILE
- Supported values:
- Either the absolute path to the webpack file or a path relative to the theme's root
- Default:
./static/build/entrypoints.json
- Supported values:
THEME_WEBPACK_ENTRY_DEFAULT
- Supported values:
- The name for the theme's default entry that should represent the bulk of the CSS and JS required to load the site.
- Default:
main
- Supported values:
add_action(
'wp_enqueue_scripts',
function()
{
\Vendi\VendiAssetLoader\Loader::enqueue_default();
}
);