@@ -70,18 +70,21 @@ export async function buildCSS(inputs, { tailwind = false } = {}) {
7070 prev : sourceMap ? JSON . stringify ( sourceMap ) : undefined ,
7171 } ,
7272 } ) ;
73- const sourceMappingURL = relative ( dirname ( output ) , sourceMapPath ) ;
7473
75- await writeFile (
76- output ,
77- // We have to manually add the sourceMappingURL comment, because
78- // `sass.compile(...)` does not do it by itself.
79- // https://sass-lang.com/documentation/js-api/interfaces/Options#sourceMap
80- // It's important to know that URI-encoding the sourceMappingURL might
81- // be needed if we start using characters outside the [0-9a-zA-Z-_.] set
82- // in file names
83- `${ postcssResult . css } \n/*# sourceMappingURL=${ sourceMappingURL } */` ,
84- ) ;
74+ const sourceMappingURL =
75+ sourceMap && relative ( dirname ( output ) , sourceMapPath ) ;
76+
77+ // We have to manually add the sourceMappingURL comment, because
78+ // `sass.compile(...)` does not do it by itself.
79+ // https://sass-lang.com/documentation/js-api/interfaces/Options#sourceMap
80+ // It's important to know that URI-encoding the sourceMappingURL might
81+ // be needed if we start using characters outside the [0-9a-zA-Z-_.] set
82+ // in file names
83+ const content = sourceMappingURL
84+ ? `${ postcssResult . css } \n/*# sourceMappingURL=${ sourceMappingURL } */`
85+ : postcssResult . css ;
86+
87+ await writeFile ( output , content ) ;
8588 await writeFile ( sourceMapPath , postcssResult . map . toString ( ) ) ;
8689 } ) ,
8790 ) ;
0 commit comments