Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Respect Vite's root config field #10

Open
ipekli opened this issue Mar 7, 2024 · 4 comments
Open

Respect Vite's root config field #10

ipekli opened this issue Mar 7, 2024 · 4 comments
Assignees

Comments

@ipekli
Copy link

ipekli commented Mar 7, 2024

I'm having trouble getting vite-plugin-php to work with my Vite setup (version 5.1.4). Despite following the plugin's documentation and configuring my vite.config.js as shown below, it doesn't seem to function as expected. My project structure is straightforward with a single index.php file in the src directory, and I've directed the plugin to use a specific PHP binary.

Here's my vite.config.js:

import path from "path";
import { defineConfig } from "vite";
import usePHP from "vite-plugin-php";

export default defineConfig({
  plugins: [
    usePHP({
      binary: "/opt/homebrew/bin/php",
      entry: ["index.php"],
    }),
  ],
  root: path.resolve(__dirname, "src"),
});

And my project structure:

- src
  -- index.php

Could anyone point out what might be wrong with this configuration or suggest any steps to troubleshoot this issue?

@ipekli
Copy link
Author

ipekli commented Mar 8, 2024

Creating a starter repository for this would be highly beneficial! It seems like a fantastic development eliminating the need for workarounds and using wildcards. However, I wasn't able to make it function correctly.

@donnikitos
Copy link
Owner

Hi @ipekli,
Vite's root config is being ignored at the moment by the plugin.
The root is assumed to be the project folder, where the vite.config.js or vite.config.ts is.
In order to load the index.php from your src folder, the config should be as follows:

import path from "path";
import { defineConfig } from "vite";
import usePHP from "vite-plugin-php";

export default defineConfig({
  plugins: [
    usePHP({
      binary: "/opt/homebrew/bin/php",
      entry: ["src/index.php"],
    }),
  ],
  root: path.resolve(__dirname, "src"),
});

Keep in mind, that you will have /src/ prefix in the URL.

Regarding the root configuration: I will implement that properly, hopefully in the near future.

@bumbummen99
Copy link

Why has this issue been closed? It does seem as this is still an issue.

@donnikitos
Copy link
Owner

I guess due to the created starter repository ;)

@donnikitos donnikitos reopened this May 9, 2024
@donnikitos donnikitos changed the title Integrating vite-plugin-php with Vite v5.1.4 Respect Vite's root config field May 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

When branches are created from issues, their pull requests are automatically linked.

3 participants