@@ -30,6 +30,12 @@ export interface ISassConfiguration {
3030 */
3131 exportAsDefault ?: boolean ;
3232
33+ /**
34+ * Files with these extensions will pass through the Sass transpiler for typings generation.
35+ * Defaults to [".sass", ".scss", ".css"]
36+ */
37+ fileExtensions ?: string [ ] ;
38+
3339 /**
3440 * A list of paths used when resolving Sass imports.
3541 * The paths should be relative to the project root.
@@ -80,9 +86,8 @@ export class SassTypingsGenerator extends StringValuesTypingsGenerator {
8086 const exportAsDefault : boolean =
8187 sassConfiguration . exportAsDefault === undefined ? true : sassConfiguration . exportAsDefault ;
8288 const exportAsDefaultInterfaceName : string = 'IExportStyles' ;
83- const fileExtensions : string [ ] = [ 'css ', 'sass ' , 'scss ' ] ;
89+ const fileExtensions : string [ ] = sassConfiguration . fileExtensions || [ '.sass ', '.scss ' , '.css ' ] ;
8490 super ( {
85- // Default configuration values
8691 srcFolder,
8792 generatedTsFolder,
8893 exportAsDefault,
@@ -92,6 +97,10 @@ export class SassTypingsGenerator extends StringValuesTypingsGenerator {
9297
9398 // Generate typings function
9499 parseAndGenerateTypings : async ( fileContents : string , filePath : string ) => {
100+ if ( this . _isSassPartial ( filePath ) ) {
101+ // Do not generate typings for Sass partials.
102+ return ;
103+ }
95104 const css : string = await this . _transpileSassAsync (
96105 fileContents ,
97106 filePath ,
@@ -110,6 +119,14 @@ export class SassTypingsGenerator extends StringValuesTypingsGenerator {
110119 } ) ;
111120 }
112121
122+ /**
123+ * Sass partial files are snippets of CSS meant to be included in other Sass files.
124+ * Partial filenames always begin with a leading underscore and do not produce a CSS output file.
125+ */
126+ private _isSassPartial ( filePath : string ) : boolean {
127+ return path . basename ( filePath ) [ 0 ] === '_' ;
128+ }
129+
113130 private async _transpileSassAsync (
114131 fileContents : string ,
115132 filePath : string ,
0 commit comments