Skip to content

Commit 410175d

Browse files
committed
Add source maps to all dispatchable resources
1 parent 47bb0fe commit 410175d

File tree

2 files changed

+13
-18
lines changed

2 files changed

+13
-18
lines changed

src/Resources/AbstractDispatchableResource.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,17 @@ protected function _processContent()
6464
{
6565
$this->_minify();
6666
}
67+
68+
if($this->getOption('sourcemap', false))
69+
{
70+
$map = $this->_filePath . '.map';
71+
if(file_exists($map))
72+
{
73+
$this->_content .= '/*# sourceMappingURL=data:application/json;charset=utf8;base64,'
74+
. base64_encode(file_get_contents($map))
75+
. '*/';
76+
}
77+
}
6778
}
6879

6980
protected function _minify() { }

src/Resources/CssResource.php

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,8 @@
66
class CssResource extends AbstractDispatchableResource
77
{
88
protected $_options = [
9-
'minify' => true,
10-
'dispatch' => true,
11-
'sourcemap' => false,
9+
'minify' => true,
10+
'dispatch' => true,
1211
];
1312

1413
public function getExtension()
@@ -66,19 +65,4 @@ protected function _minify()
6665
$this->_content = trim($this->_content);
6766
}
6867

69-
protected function _processContent()
70-
{
71-
parent::_processContent();
72-
if($this->getOption('sourcemap', false))
73-
{
74-
$map = $this->_filePath . '.map';
75-
if(file_exists($map))
76-
{
77-
$this->_content .= '/*# //@ sourceMappingURL=data:application/json;charset=utf-8;base64,'
78-
. base64_encode(file_get_contents($map))
79-
. ' /*';
80-
}
81-
}
82-
}
83-
8468
}

0 commit comments

Comments
 (0)