Skip to content

Commit b1edf50

Browse files
committed
Do not minify javascript with -min. or .min. in the path
1 parent 69eb079 commit b1edf50

File tree

3 files changed

+24
-3
lines changed

3 files changed

+24
-3
lines changed

src/Dispatch.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,7 @@ public function handle(Request $request): Response
128128
}
129129
if($resource instanceof AbstractResource)
130130
{
131+
$resource->setFilePath($fullPath);
131132
$resource->setContent(file_get_contents($fullPath));
132133
}
133134
return ResourceFactory::create($resource);

src/Resources/AbstractResource.php

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,10 @@ abstract class AbstractResource implements Resource
66
protected $_content;
77
protected $_options;
88
protected $_hash;
9+
protected $_filePath;
910

1011
/**
11-
* Get the content for this asset
12+
* Get the content for this resource
1213
*
1314
* @return mixed
1415
*/
@@ -18,7 +19,7 @@ public function getContent()
1819
}
1920

2021
/**
21-
* Set the asset content
22+
* Set the resource content
2223
*
2324
* @param $content
2425
*
@@ -30,6 +31,19 @@ public function setContent($content)
3031
return $this;
3132
}
3233

34+
/**
35+
* Set the path this asset was loaded from
36+
*
37+
* @param $path
38+
*
39+
* @return $this
40+
*/
41+
public function setFilePath($path)
42+
{
43+
$this->_filePath = $path;
44+
return $this;
45+
}
46+
3347
/**
3448
* Get the current options set
3549
*
@@ -41,7 +55,7 @@ public function getOptions()
4155
}
4256

4357
/**
44-
* Remove all options from the asset
58+
* Remove all options from the resource
4559
*
4660
* @return $this
4761
*/

src/Resources/JavascriptResource.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,12 @@ public function getContentType()
2323
public function getContent()
2424
{
2525
$data = parent::getContent();
26+
$file = basename($this->_filePath);
27+
28+
if(strpos($file, '.min.') > 0 || strpos($file, '-min.') > 0)
29+
{
30+
return $data;
31+
}
2632

2733
//Return the raw content if minification has been disabled
2834
if(!ValueAs::bool($this->getOption('minify', true)))

0 commit comments

Comments
 (0)