This repository was archived by the owner on Jan 11, 2023. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 419
[WIP, please help improve] Fix #699 when importing css using postcss #1309
Closed
Closed
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 |
|---|---|---|
|
|
@@ -39,10 +39,14 @@ export default class RollupCompiler { | |
| this.chunks.push(chunk); | ||
| }, | ||
| transform: (code: string, id: string) => { | ||
| if (/\.css$/.test(id)) { | ||
| this.css_files.push({ id, code }); | ||
| return ``; | ||
| if (!/\.css$/.test(id)) return; | ||
|
|
||
| if (/styleInject/.test(code)) { | ||
| return code; | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What's the difference between
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In this case I'm just mimicking the code that was there previously. That also either returned nothing (if the id did not test positive for |
||
| } | ||
|
|
||
| this.css_files.push({ id, code }); | ||
| return ``; | ||
| } | ||
| }); | ||
|
|
||
|
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's a lot to comprehend regarding this bug and I'm not sure I totally understand it yet because I'm not that familiar with PostCSS, etc. Looking for
styleInjectseems too specific to this usecase though and I think it'd be better handled in a more generic way. The first line of this function is checking to make sure that the code is CSS. Perhaps the issue here is that you actually have JavaScript in a file with a.cssextension? It seems weird to me that you would have that, but perhaps the fix should be to check if the file contents are JavaScript instead of CSS? But I'm not quite sure a good way of doing that. Looking for something likeexportseems a bit better, but also seems like it could cause problems. E.g. what if the user has some data export functionality on their site and has a CSS class named.export?