@@ -135,6 +135,20 @@ function cacheCssImportSpecsAbsolute(sourceFile) {
135135 } ) ;
136136}
137137
138+ function getStylesheetContent ( specifier , fileName , minify ) {
139+ let content ; let pathname ;
140+ if ( specifier . startsWith ( './' ) ) {
141+ const dir = pathToFileURL ( fileName ) ;
142+ const url = new URL ( specifier , dir ) ;
143+ ( { pathname } = url ) ;
144+ content = fs . readFileSync ( url , 'utf-8' ) ;
145+ } else {
146+ pathname = require . resolve ( specifier ) ;
147+ content = fs . readFileSync ( pathname , 'utf-8' ) ;
148+ }
149+ return minify ? minifyCss ( content , pathname ) : content ;
150+ }
151+
138152/**
139153 * Replace .css import specifiers with .css.js import specifiers
140154 * If the inline option is set, remove the import specifier and print the css
@@ -167,10 +181,7 @@ module.exports = function(program, {
167181 if ( inline ) {
168182 const cached = cssImportSpecImporterMap . get ( specifierAbs ) ;
169183 if ( cached ?. size === 1 ) {
170- const dir = pathToFileURL ( fileName ) ;
171- const url = new URL ( specifier , dir ) ;
172- const content = fs . readFileSync ( url , 'utf-8' ) ;
173- const stylesheet = minify ? minifyCss ( content , url . pathname ) : content ;
184+ const stylesheet = getStylesheetContent ( specifier , fileName , minify ) ;
174185 return [
175186 createLitCssImportStatement ( ctx , node . getSourceFile ( ) ) ,
176187 createLitCssTaggedTemplateLiteral (
0 commit comments