PHPackages                             dietr/wp-vite-integration - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. dietr/wp-vite-integration

ActiveWordpress-muplugin[Utility &amp; Helpers](/categories/utility)

dietr/wp-vite-integration
=========================

Add vite integration to your WordPress theme

v0.2.0(1y ago)04MITPHPPHP &gt;=8.0

Since Mar 12Pushed 1y ago1 watchersCompare

[ Source](https://github.com/Dietr/wp-vite-integration)[ Packagist](https://packagist.org/packages/dietr/wp-vite-integration)[ RSS](/packages/dietr-wp-vite-integration/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (2)DependenciesVersions (3)Used By (0)

Vite integration for Wordpress
==============================

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

Handles Vite integration for WordPress theme development. Inspired by .

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

[](#installation)

Via composer as mu-plugin:

```
composer require dietr/wp-vite-integration
```

Add this to your `composer.json`:

```
{
    "require": {
        "dietr/wp-vite-integration": "^0.2.0"
    }
}
```

Then run:

```
composer install
```

functions.php
-------------

[](#functionsphp)

```
// Vite integration
add_action('after_setup_theme', function() {
  $GLOBALS['vite_integration']->setConfig([
      'env_file' => get_template_directory() . '/../../../.env',
      'manifest_path' => get_template_directory() . '/dist/.vite/manifest.json',
      'manifest_uri' => get_template_directory_uri() . '/dist',
      'entry_point' => '/resources/js/index.js',
      'vite_port' => '5173'
  ]);
});

```

Vite dev server toggle
----------------------

[](#vite-dev-server-toggle)

Add this script in the root: `viteDevServerToggle.js`

```
/**
 * toggle USE_VITE_DEV_SERVER environment variable based on which npm script is running
 * */
import fs from 'fs';
import os from 'os';

export function setEnvValue(key, value) {
  // read file from hdd & split if from a linebreak to a array
  const ENV_VARS = fs.readFileSync("./.env", "utf8").split(os.EOL);

  // find the env we want based on the key
  const target = ENV_VARS.indexOf(ENV_VARS.find((line) => {
    return line.match(new RegExp(key));
  }));

  // replace the key/value with the new value
  ENV_VARS.splice(target, 1, `${key}=${value}`);

  // write everything back to the file system
  fs.writeFileSync("./.env", ENV_VARS.join(os.EOL));
}

if (process.env.NODE_ENV !== 'test') {  // Avoid running in test environment
    if (process.argv.length > 2) {
        const enable = process.argv[2];
        setEnvValue("USE_VITE_DEV_SERVER", enable);
    }
}

```

Setup your build and dev task in your `package.json`

```
  "build": "node viteDevServerToggle.js 0 && npx vite build",
  "dev": "node viteDevServerToggle.js 1 && npx vite",

```

###  Health Score

24

—

LowBetter than 32% of packages

Maintenance48

Moderate activity, may be stable

Popularity3

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity33

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% 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 ~8 days

Total

2

Last Release

414d ago

### Community

Maintainers

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

---

Top Contributors

[![Dietr](https://avatars.githubusercontent.com/u/2385322?v=4)](https://github.com/Dietr "Dietr (11 commits)")

---

Tags

pluginwordpressvite

### Embed Badge

![Health badge](/badges/dietr-wp-vite-integration/health.svg)

```
[![Health](https://phpackages.com/badges/dietr-wp-vite-integration/health.svg)](https://phpackages.com/packages/dietr-wp-vite-integration)
```

###  Alternatives

[afragen/git-updater

A plugin to automatically update GitHub, Bitbucket, GitLab, or Gitea hosted plugins, themes, and language packs.

3.3k1.6k](/packages/afragen-git-updater)[webdevstudios/cmb2-attached-posts

Custom field for CMB2 for creating post relationships.

13565.5k](/packages/webdevstudios-cmb2-attached-posts)[appsero/client

Appsero Client

25431.7k9](/packages/appsero-client)[boxybird/inertia-wordpress

The WordPress adapter for Inertia.js

1827.4k](/packages/boxybird-inertia-wordpress)[iceicetimmy/acf-post-type-selector

Post type selector for Advanced Custom Fields.

559.0k](/packages/iceicetimmy-acf-post-type-selector)[alexis-magina/cmb2-field-post-search-ajax

CMB2 field type to attach posts to each others. Search with Ajax.

3913.4k1](/packages/alexis-magina-cmb2-field-post-search-ajax)

PHPackages © 2026

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