Skip to content

Commit 1f19d0c

Browse files
committed
Add asset bundle so it can be sent to s3
1 parent 8d1a90d commit 1f19d0c

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed

src/web/AssetManager.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
use craft\cloud\Helper;
88
use craft\cloud\Module;
99
use craft\helpers\FileHelper;
10+
use craft\helpers\StringHelper;
11+
use League\Uri\Components\HierarchicalPath;
1012
use League\Uri\Modifier;
1113

1214
class AssetManager extends \craft\web\AssetManager
@@ -41,6 +43,16 @@ protected function preparePaths(): void
4143
protected function hash($path): string
4244
{
4345
$dir = is_file($path) ? dirname($path) : $path;
46+
$rebrandPath = Craft::$app->getPath()->getRebrandPath();
47+
48+
// Account for rebrand, as it lives in @storage by default,
49+
// which will be different in Cloud runtime vs. Cloud build.
50+
if (str_starts_with($dir, $rebrandPath)) {
51+
return HierarchicalPath::new(StringHelper::removeLeft($dir, $rebrandPath))
52+
->prepend('rebrand')
53+
->withoutTrailingSlash()
54+
->toString();
55+
}
4456

4557
// @phpstan-ignore-next-line
4658
$alias = Craft::alias($dir);
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?php
2+
3+
namespace craft\cloud\web\assets\rebrand;
4+
5+
use Craft;
6+
7+
class RebrandAsset extends \craft\web\AssetBundle
8+
{
9+
public function init()
10+
{
11+
$this->sourcePath = Craft::$app->getPath()->getRebrandPath();
12+
parent::init();
13+
}
14+
}

0 commit comments

Comments
 (0)