PHPackages                             idleberg/wordpress-vite-assets - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. idleberg/wordpress-vite-assets

ActiveLibrary

idleberg/wordpress-vite-assets
==============================

Injects assets from a Vite manifest to the Wordpress head, supports themes and plugins

v2.0.0(4mo ago)14816.4k↓18%151MITPHPPHP &gt;=8.2CI passing

Since Feb 21Pushed 4mo ago3 watchersCompare

[ Source](https://github.com/idleberg/php-wordpress-vite-assets)[ Packagist](https://packagist.org/packages/idleberg/wordpress-vite-assets)[ Fund](https://www.buymeacoffee.com/idleberg)[ RSS](/packages/idleberg-wordpress-vite-assets/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (10)Dependencies (10)Versions (33)Used By (1)

Vite Assets for WordPress
=========================

[](#vite-assets-for-wordpress)

> Adds assets from a [Vite](https://vitejs.dev/) manifest to the WordPress head, supports themes and plugins.

[![License](https://camo.githubusercontent.com/0340f036a787d9fd5af1f36a4effc47d22b6fb29330d27011212fe94a51fe353/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f69646c65626572672f776f726470726573732d766974652d6173736574733f7374796c653d666f722d7468652d626164676526636f6c6f723d626c7565)](https://github.com/idleberg/php-wordpress-vite-assets/blob/main/LICENSE)[![Version](https://camo.githubusercontent.com/1d0ce7bd06dc7e7b4710226fc61405d647e24d0cba18a2a9eb69c1fe5a939854/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f69646c65626572672f776f726470726573732d766974652d6173736574733f7374796c653d666f722d7468652d6261646765)](https://github.com/idleberg/php-wordpress-vite-assets/releases)[![PHP Version](https://camo.githubusercontent.com/6efd17a44f3fd5bae4d1715934977402d166c713869a8ec999bfe81f2ffa4884/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f646570656e64656e63792d762f69646c65626572672f776f726470726573732d766974652d6173736574732f7068703f7374796c653d666f722d7468652d6261646765)](https://camo.githubusercontent.com/6efd17a44f3fd5bae4d1715934977402d166c713869a8ec999bfe81f2ffa4884/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f646570656e64656e63792d762f69646c65626572672f776f726470726573732d766974652d6173736574732f7068703f7374796c653d666f722d7468652d6261646765)[![Build](https://camo.githubusercontent.com/351ad99dcd1ebb938bd7798e817ab1db2365dbaff9e3b763defdf468aaae5b6e/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f69646c65626572672f7068702d776f726470726573732d766974652d6173736574732f64656661756c742e796d6c3f7374796c653d666f722d7468652d6261646765)](https://github.com/idleberg/php-wordpress-vite-assets/actions)

**Table of contents**

- [Installation](#installation)
- [Usage](#usage)
    - [Methods](#methods)
        - [`inject()`](#inject)
        - [`getScriptTag()`](#getscripttag)
        - [`getStyleTags()`](#getstyletags)
        - [`getPreloadTags()`](#getpreloadtags)
    - [Options](#options)
        - [`option.action`](#optionaction)
        - [`option.crossorigin`](#optioncrossorigin)
        - [`option.integrity`](#optionintegrity)
        - [`option.priority`](#optionpriority)
- [License](#license)

Installation
------------

[](#installation)

`composer require idleberg/wordpress-vite-assets`

Usage
-----

[](#usage)

To get you going, first instantiate the class exposed by this library

```
new Assets(string $manifestPath, string $baseUri, string $algorithm = "sha256");
```

### Parameters

[](#parameters)

#### `$manifestPath`

[](#manifestpath)

Type: `string`

Specifies the path to the manifest.

#### `$baseUri`

[](#baseuri)

Type: `string`

Specifies the base URI for the assets in the manifest.

#### `$algorithm`

[](#algorithm)

Type: `"sha256"` |`"sha384"` |`"sha512"` | `":manifest:"`
Default: `"sha256"`

Specifies the algorithm used for hashing the assets. This will be used for [subsource integrity](https://developer.mozilla.org/en-US/docs/Web/Security/Subresource_Integrity) when printing script or style tags.

Tip

You can use `":manifest:"` in conjunction with [vite-plugin-manifest-sri](https://github.com/ElMassimo/vite-plugin-manifest-sri), a plug-in that calculates the hashes at build-time and adds them to the manifest.

**Example**

```
// functions.php

use Idleberg\WordPress\ViteAssets\Assets;

$baseUrl = get_stylesheet_directory_uri();
$manifest = "path/to/manifest.json";
$entryPoint = "index.ts";

$viteAssets = new Assets($manifest, $baseUrl);
$viteAssets->inject($entryPoint);
```

### Methods

[](#methods)

#### `inject()`

[](#inject)

Usage: `inject(array|string $entrypoints, array $options = [])`

Injects tags for entries specified in the manifest to the page header

- script entrypoint
- preloads for imported scripts
- style tags

#### `getScriptTag()`

[](#getscripttag)

Usage: `getScriptTag(string $entrypoint, array $options = [])`

Returns the script tag for an entry in the manifest

#### `getStyleTags()`

[](#getstyletags)

Usage: `getStyleTags(string $entrypoint, array $options = [])`

Returns the style tags for an entry in the manifest

#### `getPreloadTags()`

[](#getpreloadtags)

Usage: `getPreloadTags(string $entrypoint)`

Returns the preload tags for an entry in the manifest

### Options

[](#options)

#### `option.action`

[](#optionaction)

Type: `null | string`

Allows overriding the default action for the [`inject()`](#inject) method.

Warning

It's unlikely that you want to change the default action, so don't override unless you know what you're doing!

**Example**

```
// plugin.php

$viteAssets->inject("index.ts", [
	"action" => "admin_head"
]);
```

#### `option.crossorigin`

[](#optioncrossorigin)

Type: `boolean | "anonymous" | "use-credentials"`

Toggles `crossorigin` attribute on script and style tags, or assigns a value

#### `option.integrity`

[](#optionintegrity)

Type: `boolean`

Toggles `integrity` attribute on script and style tags

#### `option.priority`

[](#optionpriority)

Type: `int | array`

Allows overriding the priority for the [`inject()`](#inject) method. It allows granular control when provided as an array:

**Example**

```
// functions.php

$viteAssets->inject("index.ts", [
	"priority" => [
		"scripts"  => 10,
		"preloads" => 0,
		"styles"   => 20
	]
]);
```

License
-------

[](#license)

This work is licensed under [The MIT License](LICENSE).

###  Health Score

57

—

FairBetter than 98% of packages

Maintenance76

Regular maintenance activity

Popularity43

Moderate usage in the ecosystem

Community22

Small or concentrated contributor base

Maturity72

Established project with proven stability

 Bus Factor1

Top contributor holds 94.7% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~50 days

Recently: every ~109 days

Total

29

Last Release

128d ago

Major Versions

v0.10.1 → v1.0.02023-11-26

v1.2.4 → v2.0.02026-01-10

PHP version history (6 changes)v0.1.0PHP &gt;=7.0.0

v0.2.2PHP ^7.3 || ^8.0

v0.4.0PHP ^7.4 || ^8.0

v0.8.0PHP &gt;=8.0

v1.0.0PHP &gt;=8.1

v2.0.0PHP &gt;=8.2

### Community

Maintainers

![](https://www.gravatar.com/avatar/e8ff89e309c7de4705011518a7ade125b6bec52b8f5a3fd55c785d0b3ba3ecc3?d=identicon)[idleberg](/maintainers/idleberg)

---

Top Contributors

[![idleberg](https://avatars.githubusercontent.com/u/1504938?v=4)](https://github.com/idleberg "idleberg (198 commits)")[![szepeviktor](https://avatars.githubusercontent.com/u/952007?v=4)](https://github.com/szepeviktor "szepeviktor (3 commits)")[![gRoberts84](https://avatars.githubusercontent.com/u/348184?v=4)](https://github.com/gRoberts84 "gRoberts84 (2 commits)")[![dst-jan](https://avatars.githubusercontent.com/u/217981129?v=4)](https://github.com/dst-jan "dst-jan (2 commits)")[![Tofandel](https://avatars.githubusercontent.com/u/6115458?v=4)](https://github.com/Tofandel "Tofandel (1 commits)")[![epigeyre](https://avatars.githubusercontent.com/u/9139722?v=4)](https://github.com/epigeyre "epigeyre (1 commits)")[![mandrasch](https://avatars.githubusercontent.com/u/777278?v=4)](https://github.com/mandrasch "mandrasch (1 commits)")[![toddheslin](https://avatars.githubusercontent.com/u/1883112?v=4)](https://github.com/toddheslin "toddheslin (1 commits)")

---

Tags

manifest-jsonvitevitejswordpresswordpressvitevitejsvite manifest

###  Code Quality

TestsCodeception

Static AnalysisPHPStan

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/idleberg-wordpress-vite-assets/health.svg)

```
[![Health](https://phpackages.com/badges/idleberg-wordpress-vite-assets/health.svg)](https://phpackages.com/packages/idleberg-wordpress-vite-assets)
```

###  Alternatives

[wp-cli/wp-cli

WP-CLI framework

5.1k17.2M320](/packages/wp-cli-wp-cli)[wp-coding-standards/wpcs

PHP\_CodeSniffer rules (sniffs) to enforce WordPress coding conventions

2.8k42.5M1.6k](/packages/wp-coding-standards-wpcs)[composer/installers

A multi-framework Composer library installer

1.4k136.0M6.0k](/packages/composer-installers)[pentatrion/vite-bundle

Vite integration for your Symfony app

2755.3M13](/packages/pentatrion-vite-bundle)[phpcompatibility/phpcompatibility-wp

A ruleset for PHP\_CodeSniffer to check for PHP cross-version compatibility issues in projects, while accounting for polyfills provided by WordPress.

22130.6M587](/packages/phpcompatibility-phpcompatibility-wp)[szepeviktor/phpstan-wordpress

WordPress extensions for PHPStan

3287.8M898](/packages/szepeviktor-phpstan-wordpress)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
