File tree 1 file changed +13
-2
lines changed
1 file changed +13
-2
lines changed Original file line number Diff line number Diff line change 1
1
<?php
2
2
3
+ use MODX \Revolution \modNamespace ;
4
+
3
5
class StercCspHomeManagerController extends \MODX \Revolution \modExtraManagerController
4
6
{
5
7
public function loadCustomCssJs (): void
6
8
{
9
+ $ nsKey = 'sterc-csp ' ;
10
+
7
11
$ server = '127.0.0.1 ' ;
8
12
$ port = getenv ('NODE_DEV_PORT ' ) ?: '9090 ' ;
9
13
$ connection = @fsockopen ($ server , $ port );
10
- $ baseUrl = MODX_ASSETS_URL . 'components/sterc-csp/ ' ;
14
+ // $baseUrl = MODX_ASSETS_URL . 'components/sterc-csp/';
15
+
16
+ $ namespace = $ this ->modx ->getObject (modNamespace::class, ['name ' => $ nsKey ]);
17
+ $ assetsPath = $ namespace ? $ namespace ->getAssetsPath () : MODX_ASSETS_PATH . 'components/ ' . $ nsKey . '/ ' ;
18
+ $ baseUrl = str_replace (MODX_BASE_PATH , '/ ' , $ assetsPath ) . 'dist/ ' ;
19
+
11
20
if (is_resource ($ connection )) {
12
21
// Development mode
13
22
$ path = $ server . ': ' . $ port . $ baseUrl ;
14
23
$ this ->addHtml ('<script type="module" src="// ' . $ path . '@vite/client"></script> ' );
15
24
$ this ->addHtml ('<script type="module" src="// ' . $ path . 'src/main.ts"></script> ' );
16
25
} else {
17
26
// Production mode
18
- $ manifest = MODX_ASSETS_PATH . 'components/sterc-csp/manifest.json ' ;
27
+ // $manifest = MODX_ASSETS_PATH . 'components/sterc-csp/manifest.json';
28
+ $ manifest = $ assetsPath . 'dist/manifest.json ' ;
29
+
19
30
if (file_exists ($ manifest ) && $ files = json_decode (file_get_contents ($ manifest ), true )) {
20
31
foreach ($ files as $ file ) {
21
32
if (preg_match ('#\.js$# ' , $ file ['file ' ])) {
You can’t perform that action at this time.
0 commit comments