Skip to content

Commit

Permalink
Update getCSSModuleLocalIdent to support Sass (facebook#4391)
Browse files Browse the repository at this point in the history
* Update getCSSModuleLocalIdent to support Sass

* Fix Sass/SCSS index module tests

Also make them more consistent with the non-index variants.
  • Loading branch information
arianon authored and Timer committed May 8, 2018
1 parent 8dedcfc commit 848e579
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 2 deletions.
10 changes: 10 additions & 0 deletions fixtures/kitchensink/integration/webpack.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,11 @@ describe('Integration', () => {
).to.match(
/.+scss-styles_scssModulesInclusion.+\{background:.+;color:.+}/
);
expect(
doc.getElementsByTagName('style')[1].textContent.replace(/\s/g, '')
).to.match(
/.+assets_scssModulesIndexInclusion.+\{background:.+;color:.+}/
);
});

it('sass inclusion', async () => {
Expand All @@ -68,6 +73,11 @@ describe('Integration', () => {
).to.match(
/.+sass-styles_sassModulesInclusion.+\{background:.+;color:.+}/
);
expect(
doc.getElementsByTagName('style')[1].textContent.replace(/\s/g, '')
).to.match(
/.+assets_sassModulesIndexInclusion.+\{background:.+;color:.+}/
);
});

it('graphql files inclusion', async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,13 @@

import React from 'react';
import styles from './assets/sass-styles.module.sass';
import indexStyles from './assets/index.module.sass';

export default () => (
<p className={styles.sassModulesInclusion}>SASS Modules are working!</p>
<div>
<p className={styles.sassModulesInclusion}>SASS Modules are working!</p>
<p className={indexStyles.sassModulesIndexInclusion}>
SASS Modules with index are working!
</p>
</div>
);
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,13 @@

import React from 'react';
import styles from './assets/scss-styles.module.scss';
import indexStyles from './assets/index.module.scss';

export default () => (
<p className={styles.scssModulesInclusion}>SCSS Modules are working!</p>
<div>
<p className={styles.scssModulesInclusion}>SCSS Modules are working!</p>
<p className={indexStyles.scssModulesIndexInclusion}>
SCSS Modules with index are working!
</p>
</div>
);
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
.sassModulesIndexInclusion
background: darkblue
color: lightblue

Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
.scssModulesIndexInclusion {
background: darkblue;
color: lightblue;
}

0 comments on commit 848e579

Please sign in to comment.