-
Notifications
You must be signed in to change notification settings - Fork 40
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Capture sass warnings, emit them as esbuild warnings
Sass just logs warnings as they occur. This is a bit of a sub-par experience with esbuild, and it would be nicer if the warnings were emitted by esbuild as it does other warnings/errors. There is some awkwardness to capturing the warnings: sass's API seems a bit stuck in some pre-async design patterns, and having a separate logger that gets called with syntax warnings rather than returning them as part of the compile result is one symptom of that. Accomplishing this with config outside the plugin is feasible but annoying. It requires writing a wrapper plugin around `sassPlugin` that wraps the `onLoad` handler to append captured warnings, plus an `onStart` handler to clear warnings (for watch mode). Additionally, if the build config has multiple entrypoints it's impossible to tell which file a warning in an entrypoint came from: warnings directly within an entrypoint don't have a `url` on the warning message (since this plugin reads the file and passes the contents to `sass.renderString`). Implemented within the plugin's renderer, this can be worked around easily since there's only ever one entrypoint in scope. So I think the cleanest way to capture this data is to construct the logger & store the warnings as close to the `sass.renderString` call as reasonable. My hope is others will also see this as a useful default behavior!
- Loading branch information
Showing
6 changed files
with
115 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
div |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
body | ||
font-size: 12px | ||
|
||
p | ||
|
||
a | ||
color: red |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
@import "./index" | ||
@import "./partial" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters