Skip to content

Commit

Permalink
Fix: allow block specific styles to be scss/sass files (#440)
Browse files Browse the repository at this point in the history
  • Loading branch information
fabiankaegy authored Feb 26, 2025
1 parent d005002 commit 394b2db
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 5 deletions.
5 changes: 5 additions & 0 deletions .changeset/lovely-grapes-call.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"10up-toolkit": patch
---

Fix: Allow Block Specific stylesheets to be scss/sass files
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
.wp-block-group {

@media (--bp-small) {
padding: 40px;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ describe('build a project', () => {
cwd: __dirname,
});

const frontendCss = path.join(
const headingBlockCSS = path.join(
__dirname,
'dist',
'blocks',
Expand All @@ -18,16 +18,28 @@ describe('build a project', () => {
'heading.css',
);

expect(fs.existsSync(frontendCss)).toBeTruthy();
const groupBlockCSS = path.join(
__dirname,
'dist',
'blocks',
'autoenqueue',
'core',
'group.css',
);

expect(fs.existsSync(headingBlockCSS)).toBeTruthy();
expect(fs.existsSync(groupBlockCSS)).toBeTruthy();
expect(
fs.existsSync(
path.join(__dirname, 'dist', 'blocks', 'autoenqueue', 'core', 'heading.asset.php'),
),
).toBeTruthy();

const compiledCSS = fs.readFileSync(frontendCss).toString();
const compiledHeadingBlockCSS = fs.readFileSync(headingBlockCSS).toString();
const compiledGroupBlockCSS = fs.readFileSync(groupBlockCSS).toString();

// expect the compiled CSS to contain "min-width: 30em"
expect(compiledCSS).toMatch('min-width: 30em');
expect(compiledHeadingBlockCSS).toMatch('min-width: 30em');
expect(compiledGroupBlockCSS).toMatch('min-width: 30em');
});
});
2 changes: 1 addition & 1 deletion packages/toolkit/config/webpack/entry.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ module.exports = ({
);

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

Expand Down

0 comments on commit 394b2db

Please sign in to comment.