Skip to content

Commit

Permalink
bug #11 Fixing bug where Tailwind compiler might run after core compi…
Browse files Browse the repository at this point in the history
…ler handling url() in CSS files (weaverryan)

This PR was merged into the main branch.

Discussion
----------

Fixing bug where Tailwind compiler might run after core compiler handling url() in CSS files

Fixes #10

Commits
-------

383655a Fixing bug where Tailwind compiler might run after core comiler handling url() in CSS files
  • Loading branch information
weaverryan committed Jun 30, 2023
2 parents 30b9ee7 + 383655a commit 5fc2926
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 3 deletions.
5 changes: 4 additions & 1 deletion config/services.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@
->args([
service('tailwind.builder')
])
->tag('asset_mapper.compiler')
->tag('asset_mapper.compiler', [
// run before core CssAssetUrlCompiler that resolves url() references
'priority' => 10,
])
;
};
12 changes: 10 additions & 2 deletions tests/FunctionalTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,13 @@ protected function setUp(): void
$fs->remove($tailwindVarDir);
}
$fs->mkdir($tailwindVarDir);
file_put_contents($tailwindVarDir.'/tailwind.built.css', 'the built css');
file_put_contents($tailwindVarDir.'/tailwind.built.css', <<<EOF
body {
padding: 17px;
background-image: url('../images/penguin.png');
}
EOF
);
}

protected function tearDown(): void
Expand All @@ -42,6 +48,8 @@ public function testBuiltCSSFileIsUsed(): void

$asset = $assetMapper->getAsset('styles/app.css');
$this->assertInstanceOf(MappedAsset::class, $asset);
$this->assertSame('the built css', $asset->content);
$this->assertStringContainsString('padding: 17px', $asset->content);
// verify the core CSS compiler that handles url() was executed
$this->assertMatchesRegularExpression('/penguin-[a-f0-9]{32}\.png/', $asset->content);
}
}
Binary file added tests/fixtures/assets/images/penguin.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 5fc2926

Please sign in to comment.