Skip to content

Commit

Permalink
Remove all css imports from result instead only from variables.scss (…
Browse files Browse the repository at this point in the history
…T1265287) (#28534)
  • Loading branch information
GoodDayForSurf authored Dec 13, 2024
1 parent 49f1508 commit 9b90a29
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -77,17 +77,17 @@ export default class BootstrapExtractor {
}

const result = `${functions}
${this.getVariables(variables)}
${variables}
${variablesDark}
${this.input}
${this.getSetterServiceCode('!default')}
${this.getCollectorServiceCode()}`;

return result;
return this.removeImports(result);
}

getVariables(variables: string): string {
return variables.replace(/^@import "variables-dark";.*$/gm, '');
removeImports(content: string): string {
return content.replace(/^@import "variables-dark";.*$/gm, '');
}

getFilePath(fileName: string): string {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,18 @@ describe('BootstrapExtractor', () => {
extractor.getSetterServiceCode = (): string => setterServiceCode;
extractor.getCollectorServiceCode = (): string => collectorServiceCode;

expect(await extractor.sassProcessor())
.toBe(`${functions.toString()}
${extractor.getVariables(variables.toString())}
const result = await extractor.sassProcessor();

expect(result.includes('@import "variables-dark";')).toBeFalsy();

const expectedResult = `${functions.toString()}
${variables.toString()}
${variablesDark.toString()}
${testSassString}
${setterServiceCode}
${collectorServiceCode}`);
${collectorServiceCode}`;

expect(result).toBe(extractor.removeImports(expectedResult));
});

test('getSetterServiceCode', () => {
Expand Down

0 comments on commit 9b90a29

Please sign in to comment.