Skip to content

Fail dist build when for postcss warnings #2180

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

Merged
merged 2 commits into from
Jul 29, 2022
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/rotten-phones-ring.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@primer/css": patch
---

Fail dist build when for postcss warnings
9 changes: 9 additions & 0 deletions script/dist.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,15 @@ async function dist() {
const scss = await readFile(from, encoding)
meta.imports = getExternalImports(scss, path).map(getPathName)
const result = await compiler(scss, {from, to})
const warnings = result.warnings()

// We don't want to release changes that cause warnings with postcss. Fail the dist build if any warnings are detected.
if (warnings.length) {
for (const warning of warnings) {
console.warn(warning.toString())
}
throw new Error(`Warnings while compiling ${from}. See output above.`)
}

await Promise.all([
writeFile(to, result.css, encoding),
Expand Down