wp-performance/presswind-assets
最新稳定版本:0.0.13
Composer 安装命令:
composer require wp-performance/presswind-assets
包简介
Assets helpers for use Vite JS in WordPress
README 文档
README
This code give you the ability to use methods of the Presswind directly in your theme for use Vite JS.
Find the package on Packagist
PWVite
port - default 3000
path - from your theme root
position front|admin|editor - default front
is_ts - default false
is_plugin true|false - default false - for search assets in plugin folder
instead of theme folder
slug - handle - default presswind-script
is_https - default true - for https or http
main_file - default main - file name without extension
use PressWind\PWVite; // use with named parameters for more readability // in theme // 1 - search dist folder in root theme PWVite::init(port: 3000, path: ''); // 2 - search admin/dist folder in root theme PWVite::init(port: 4444, path: 'admin', position: 'admin', is_ts: false); // in plugin // 3 - search dist folder in plugin test-plugin (from index.php root plugin) PWVite::init( port: 7777, path: 'test-plugin/', plugin_path: __FILE__, slug: 'plugin-test' );
Preload fonts
PWVite::init()->setPreloadFont();
PWAssets
use PressWind\PWAssets; // for css PWAsset::add('my-css', get_template_directory_uri().'/assets/style.css')->dependencies([])->media('all')->version('1.0.0')->toFront(); PWAsset::add('my-css', get_template_directory_uri().'/assets/style.css')->dependencies([])->media('all')->version('1.0.0')->toBack(); PWAsset::add('my-css', get_template_directory_uri().'/assets/style.css')->dependencies([])->media('all')->version('1.0.0')->toBlock(); PWAsset::add('my-css', get_template_directory_uri().'/assets/style.css')->dependencies([])->media('all')->version('1.0.0')->toLogin(); // for js PWAsset::add('my-js', get_template_directory_uri().'/assets/js/app.js') ->dependencies(['jquery']) ->version('1.0.0') ->module() ->toFront() ->withInline('console.log("hello world")'); PWAsset::add('my-js', get_template_directory_uri().'/assets/js/app.js') ->dependencies(['jquery']) ->version('1.0.0') ->noModule() ->toFront(); PWAsset::add('my-js', get_template_directory_uri().'/assets/js/app.js') ->dependencies(['jquery']) ->version('1.0.0') ->async() ->inFooter() ->toFront(); PWAsset::add('my-js', get_template_directory_uri().'/assets/js/app.js') ->dependencies(['jquery']) ->version('1.0.0') ->defer() ->inFooter() ->toFront(); PWAsset::add('my-js', get_template_directory_uri().'/assets/js/app.js') ->dependencies(['jquery']) ->version('1.0.0') ->defer() ->inFooter() ->toBack(); PWAsset::add('my-js', get_template_directory_uri().'/assets/js/app.js') ->dependencies(['jquery']) ->version('1.0.0') ->defer() ->inFooter() ->toBlock();
统计信息
- 总下载量: 3.15k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 4
- 点击次数: 1
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2023-11-20