Skip to content

Commit 394b2db

Browse files
authored
Fix: allow block specific styles to be scss/sass files (#440)
1 parent d005002 commit 394b2db

File tree

4 files changed

+28
-5
lines changed

4 files changed

+28
-5
lines changed

.changeset/lovely-grapes-call.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"10up-toolkit": patch
3+
---
4+
5+
Fix: Allow Block Specific stylesheets to be scss/sass files
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
.wp-block-group {
2+
3+
@media (--bp-small) {
4+
padding: 40px;
5+
}
6+
}

packages/toolkit/__tests__/build-project-block-specific-css/test.js

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ describe('build a project', () => {
99
cwd: __dirname,
1010
});
1111

12-
const frontendCss = path.join(
12+
const headingBlockCSS = path.join(
1313
__dirname,
1414
'dist',
1515
'blocks',
@@ -18,16 +18,28 @@ describe('build a project', () => {
1818
'heading.css',
1919
);
2020

21-
expect(fs.existsSync(frontendCss)).toBeTruthy();
21+
const groupBlockCSS = path.join(
22+
__dirname,
23+
'dist',
24+
'blocks',
25+
'autoenqueue',
26+
'core',
27+
'group.css',
28+
);
29+
30+
expect(fs.existsSync(headingBlockCSS)).toBeTruthy();
31+
expect(fs.existsSync(groupBlockCSS)).toBeTruthy();
2232
expect(
2333
fs.existsSync(
2434
path.join(__dirname, 'dist', 'blocks', 'autoenqueue', 'core', 'heading.asset.php'),
2535
),
2636
).toBeTruthy();
2737

28-
const compiledCSS = fs.readFileSync(frontendCss).toString();
38+
const compiledHeadingBlockCSS = fs.readFileSync(headingBlockCSS).toString();
39+
const compiledGroupBlockCSS = fs.readFileSync(groupBlockCSS).toString();
2940

3041
// expect the compiled CSS to contain "min-width: 30em"
31-
expect(compiledCSS).toMatch('min-width: 30em');
42+
expect(compiledHeadingBlockCSS).toMatch('min-width: 30em');
43+
expect(compiledGroupBlockCSS).toMatch('min-width: 30em');
3244
});
3345
});

packages/toolkit/config/webpack/entry.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ module.exports = ({
117117
);
118118

119119
// get all stylesheets in the blocks directory
120-
const stylesheets = glob(`${blockStylesheetDirectory}/**/*.css`, {
120+
const stylesheets = glob(`${blockStylesheetDirectory}/**/*.{css,scss,sass}`, {
121121
absolute: true,
122122
});
123123

0 commit comments

Comments
 (0)