Skip to content

Commit

Permalink
Tweaks the replace or append action
Browse files Browse the repository at this point in the history
  • Loading branch information
tonysm committed Feb 23, 2024
1 parent 021f805 commit d933eda
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/Actions/ReplaceOrAppendTags.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@

class ReplaceOrAppendTags
{
public const VITE_DIRECTIVE_PATTERN = '/(\s*)\@vite\(.+\)/';
public const VITE_DIRECTIVE_PATTERN = '/(\s*)\@vite\(.*\)/';
public const CLOSING_HEAD_TAG_PATTERN = '/(\s*)(<\/head>)/';

public function __invoke(string $contents)
{
if (preg_match(self::VITE_DIRECTIVE_PATTERN, $contents)) {
if (str_contains($contents, '@vite')) {
return preg_replace(
static::VITE_DIRECTIVE_PATTERN,
"\\1<x-importmap::tags />",
Expand Down
2 changes: 1 addition & 1 deletion tests/ReplaceOrAppendTagsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public function replace_vite_tags()
<link href="https://fonts.bunny.net/css?family=figtree:400,500,600&display=swap" rel="stylesheet" />
<!-- Scripts -->
@vite(['resources/js/app.js', 'resources/css/app.css'])
@vite(['resources/css/app.css', 'resources/js/app.js'])
</head>
<body class="font-sans antialiased">
<!-- ... -->
Expand Down

0 comments on commit d933eda

Please sign in to comment.