* allow use dev vitejs build without manifest reader
This commit is contained in:
@ -61,6 +61,10 @@ class TwigFilters
|
||||
$bundler->validateBundlerType(Bundler::BUNDLER_VITE);
|
||||
assert($bundler instanceof ViteBundler);
|
||||
|
||||
if ($bundler->isViteDevEnabled()) {
|
||||
return '';
|
||||
}
|
||||
|
||||
return $bundler->getEntrypointStylesheets($entrypointName);
|
||||
}
|
||||
|
||||
@ -76,7 +80,11 @@ class TwigFilters
|
||||
$bundler->validateBundlerType(Bundler::BUNDLER_VITE);
|
||||
assert($bundler instanceof ViteBundler);
|
||||
|
||||
return $bundler->getEntrypointAssets($entrypointName);
|
||||
if ($bundler->isViteDevEnabled()) {
|
||||
return $bundler->getScriptTag($entrypointName);
|
||||
} else {
|
||||
return $bundler->getEntrypointAssets($entrypointName);
|
||||
}
|
||||
}
|
||||
|
||||
public static function viteDevClientScriptTag()
|
||||
|
@ -13,11 +13,13 @@ abstract class Bundler
|
||||
self::BUNDLER_VITE => ViteBundler::class,
|
||||
];
|
||||
|
||||
protected ManifestReader $manifestReader;
|
||||
protected ?ManifestReader $manifestReader;
|
||||
|
||||
public function __construct(ManifestReader $manifestReader)
|
||||
public function __construct(?ManifestReader $manifestReader = null)
|
||||
{
|
||||
$this->manifestReader = $manifestReader;
|
||||
if (isset($manifestReader)) {
|
||||
$this->manifestReader = $manifestReader;
|
||||
}
|
||||
}
|
||||
|
||||
public function getBundlerType(): string
|
||||
|
@ -60,10 +60,6 @@ class ViteBundler extends Bundler
|
||||
*/
|
||||
public function getEntrypointStylesheets(string $entrypointName): string
|
||||
{
|
||||
if ($this->isViteDevEnabled()) {
|
||||
return '';
|
||||
}
|
||||
|
||||
$entrypoint = $this->getViteEntrypoint($entrypointName);
|
||||
|
||||
$stylesheetTags = collect();
|
||||
@ -85,7 +81,7 @@ class ViteBundler extends Bundler
|
||||
return $stylesheetTags->implode(PHP_EOL);
|
||||
}
|
||||
|
||||
private function getStylesheetTag(string $href): string
|
||||
public function getStylesheetTag(string $href): string
|
||||
{
|
||||
return sprintf(
|
||||
'<link rel="stylesheet" href="%s">',
|
||||
@ -93,7 +89,7 @@ class ViteBundler extends Bundler
|
||||
);
|
||||
}
|
||||
|
||||
private function getScriptTag(string $entrypointName, ViteEntrypoint $entrypoint): string
|
||||
public function getScriptTag(string $entrypointName, ?ViteEntrypoint $entrypoint = null): string
|
||||
{
|
||||
return sprintf(
|
||||
'<script type="module" src="%s" %s></script>',
|
||||
|
Reference in New Issue
Block a user