vite-plugin-php 1.0.50 → 1.0.55
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -0
- package/dist/router.php +16 -6
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -22,6 +22,7 @@ Check out the [starter repo](https://github.com/nititech/php-vite-starter) for a
|
|
|
22
22
|
|
|
23
23
|
| Version | Feature |
|
|
24
24
|
| ------- | ------------------------------------------------------------------------------------- |
|
|
25
|
+
| 1.0.55 | Auto close last PHP tag if not close (usually PHP only files) |
|
|
25
26
|
| 1.0.50 | Using native Rollup pipeline to generate bundle -> proper error messages during build |
|
|
26
27
|
| 1.0.40 | Vite's "HTML Env Replacement" feature in transpiled PHP files |
|
|
27
28
|
| 1.0.30 | Proper PHP header forwarding during development |
|
package/dist/router.php
CHANGED
|
@@ -14,13 +14,23 @@ $_SERVER['SCRIPT_FILENAME'] = $_SERVER['DOCUMENT_ROOT'] . $_SERVER['SCRIPT_NAME'
|
|
|
14
14
|
$_SERVER['QUERY_STRING'] = http_build_query($_GET);
|
|
15
15
|
|
|
16
16
|
$source = file_get_contents($sourceFile);
|
|
17
|
-
$codeTokens = json_decode(file_get_contents("$sourceFile.json"), true);
|
|
18
17
|
|
|
19
|
-
$
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
18
|
+
$tokensFile = "$sourceFile.json";
|
|
19
|
+
if (file_exists($tokensFile)) {
|
|
20
|
+
$codeTokens = json_decode(file_get_contents($tokensFile), true);
|
|
21
|
+
|
|
22
|
+
$source = str_replace(
|
|
23
|
+
array_keys($codeTokens),
|
|
24
|
+
array_values($codeTokens),
|
|
25
|
+
$source,
|
|
26
|
+
);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
preg_match('#<\?((?!\?>).)*$#s', $source, $matches);
|
|
30
|
+
|
|
31
|
+
if (count($matches)) {
|
|
32
|
+
$source .= ' ?>';
|
|
33
|
+
}
|
|
24
34
|
|
|
25
35
|
(function () {
|
|
26
36
|
try {
|