Skip to content

Recompile Sass after exception when watching files#7009

Merged
aduth merged 2 commits intomainfrom
aduth-sass-recompile-error
Sep 22, 2022
Merged

Recompile Sass after exception when watching files#7009
aduth merged 2 commits intomainfrom
aduth-sass-recompile-error

Conversation

@aduth
Copy link
Contributor

@aduth aduth commented Sep 22, 2022

Why: So that a developer has an opportunity to fix a compilation error, and so that they're not confused when their changes are not reflected in the running application process.

Currently, if a developer is running make run and introduces a syntax error to a stylesheet, the stylesheet build process will crash and never recover. The application will continue to run, however, causing confusion for the developer.

Testing Instructions:

  • Try adding an intentional syntax error to a stylesheet while make run is running, observe the error in the console, and observe that the files are recompiled when the syntax error is fixed.
    • Note: There is (currently) no feedback for rebuilds in the terminal process, but you should notice changes being reflected in the application after refresh shortly after the file is saved.
  • Ensure that syntax errors continue to exit with a non-zero status code when not watching.
diff --git a/app/assets/stylesheets/utilities/_typography.scss b/app/assets/stylesheets/utilities/_typography.scss
index 9b8678f5b..c8a122482 100644
--- a/app/assets/stylesheets/utilities/_typography.scss
+++ b/app/assets/stylesheets/utilities/_typography.scss
@@ -99,3 +99,11 @@ h6,
 .h6 {
   @extend %h6;
 }
+
+.example {
+  background: $broken;
+}
+
+h1 {
+  color: red !important;
+}
yarn build:css
echo $?
# 1

**Why**: So that a developer has an opportunity to fix a compilation error, and so that they're not confused when their changes are not reflected in the running application process.

changelog: Internal, Build Tooling, Recompile CSS after error in local development
@aduth aduth requested a review from jmdembe September 22, 2022 13:35
A bit clearer to interpret I think
@aduth
Copy link
Contributor Author

aduth commented Sep 22, 2022

I suspect this also has another benefit, which is that previously if someone added a new .scss file while the process is running / watching, changes to that file would not trigger a rebuild, since loadedPaths was only evaluated at the initial build. With the recursion introduced here, it would be evaluated at each rebuild.

@aduth aduth merged commit 90ac2c1 into main Sep 22, 2022
@aduth aduth deleted the aduth-sass-recompile-error branch September 22, 2022 16:06
@solipet solipet mentioned this pull request Sep 26, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants