Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: allow block specific styles to be scss/sass files #440

Merged
merged 2 commits into from
Feb 26, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading