vendi-advertising / vendi-asset-loader
Dynamically enqueue CSS and JS files
Installs: 563
Dependents: 0
Suggesters: 0
Security: 0
Stars: 1
Watchers: 1
Forks: 0
Open Issues: 0
pkg:composer/vendi-advertising/vendi-asset-loader
Requires
- php: ^8.0|^8.1|^8.2|^8.3|^8.4
- symfony/filesystem: ^6|^7
- webmozart/glob: ^4.6
Requires (Dev)
- mikey179/vfsstream: ^1.6
- phpunit/phpunit: ^8|^9
README
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.
Install
composer require vendi-advertising/vendi-asset-loader:^2
Configure
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_MODEandTHEME_JS_MODEintostaticmodestage- 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]-*.cssstatic- Loads CSS files as defined in the webpack encore entry file
- Usage notes:
- If
THEME_MODEis set toprod, this configured value is ignore and insteadstaticis 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]-*.jsstatic- Loads JS files as defined in the webpack encore entry file
- Usage notes:
- If
THEME_MODEis set toprod, this configured value is ignore and insteadstaticis 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:
Usage
add_action(
'wp_enqueue_scripts',
function()
{
\Vendi\VendiAssetLoader\Loader::enqueue_default();
}
);