@@ -150,30 +150,31 @@ protected function runCompile(array $payload): string
150150
151151 protected function processSourceMap (array $ sourceMap , array $ options ): string
152152 {
153- if (! empty ($ options ['sourceMapPath ' ])) {
154- $ mapFile = (string ) $ options ['sourceMapPath ' ];
155-
156- $ isUrl = filter_var ($ mapFile , FILTER_VALIDATE_URL ) !== false ;
157- if ($ isUrl ) {
158- $ sourceMappingUrl = $ mapFile ;
159- } else {
160- if (is_dir ($ mapFile )) {
161- $ sourceFilename = $ this ->getSourceFilenameFromUrl ($ options ['url ' ] ?? '' );
162- $ mapFile .= DIRECTORY_SEPARATOR . $ sourceFilename . '.map ' ;
163- } elseif (strtolower (substr ($ mapFile , -4 )) !== '.map ' ) {
164- $ mapFile .= '.map ' ;
165- }
166-
167- file_put_contents ($ mapFile , json_encode ($ sourceMap ));
168- $ sourceMappingUrl = basename ($ mapFile );
169- }
170-
171- return "\n/*# sourceMappingURL= " . $ sourceMappingUrl . " */ " ;
172- } else {
153+ if (empty ($ options ['sourceMapPath ' ])) {
173154 $ mapData = json_encode ($ sourceMap );
174155 $ encodedMap = base64_encode ($ mapData );
156+
175157 return "\n/*# sourceMappingURL=data:application/json;base64, " . $ encodedMap . " */ " ;
176158 }
159+
160+ $ mapFile = (string ) $ options ['sourceMapPath ' ];
161+
162+ $ isUrl = filter_var ($ mapFile , FILTER_VALIDATE_URL ) !== false ;
163+ if ($ isUrl ) {
164+ $ sourceMappingUrl = $ mapFile ;
165+ } else {
166+ if (is_dir ($ mapFile )) {
167+ $ sourceFilename = $ this ->getSourceFilenameFromUrl ($ options ['url ' ] ?? '' );
168+ $ mapFile .= DIRECTORY_SEPARATOR . $ sourceFilename . '.map ' ;
169+ } elseif (strtolower (substr ($ mapFile , -4 )) !== '.map ' ) {
170+ $ mapFile .= '.map ' ;
171+ }
172+
173+ file_put_contents ($ mapFile , json_encode ($ sourceMap ));
174+ $ sourceMappingUrl = basename ($ mapFile );
175+ }
176+
177+ return "\n/*# sourceMappingURL= " . $ sourceMappingUrl . " */ " ;
177178 }
178179
179180 protected function getSourceFilenameFromUrl (string $ url ): string
0 commit comments