Skip to content

Leave .css files un-transformed #28

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 14, 2019
Merged

Leave .css files un-transformed #28

merged 2 commits into from
Jul 14, 2019

Conversation

jgoz
Copy link
Contributor

@jgoz jgoz commented Jul 11, 2019

Projects using PostCSS may have enabled plugins which can result in .css files that cannot be parsed by the Sass compiler. In my case, the postcss-mixins plugin uses a reserved Sass at-rule (@mixin) in an incompatible way, causing the transformer to fail.

Since PostCSS is able to extract nested selectors without any kind of transformation, we can pass in the source as-is for plain CSS files.

Projects using PostCSS may have enabled Sass-incompatible plugins
which can result in .css files that cannot be parsed by the Sass
compiler.

Since PostCSS is able to extract nested selectors without any kind
of transformation, we can pass in the source as-is.
Copy link
Owner

@mrmckeb mrmckeb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this, it looks great. Just one suggested change.

I should also point out that this would allow for limited PostCSS support - as things like nesting would still cause the file to fail.

}

export const getFileType = (fileName: string) =>
fileName.endsWith('less') ? FileTypes.less : FileTypes.scss;
fileName.endsWith('.css')
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rather than a nested ternary, we could use switch or if statements. If it's CSS or LESS, return those types, otherwise assume SASS.

Copy link
Owner

@mrmckeb mrmckeb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll merge this and resolve the ternary, as I'm working on another fix anyway and don't want to create conflicts for you.

Thanks for your time on this!

@mrmckeb mrmckeb merged commit deca4ad into mrmckeb:develop Jul 14, 2019
@jgoz
Copy link
Contributor Author

jgoz commented Jul 14, 2019

Thank you for the review!

I should also point out that this would allow for limited PostCSS support - as things like nesting would still cause the file to fail.

According to your snapshot tests, nesting continues to work, even with plain PostCSS. What will not work are syntax extensions that generate selectors, as this would require loading such plugins.

@mrmckeb
Copy link
Owner

mrmckeb commented Jul 14, 2019

Sorry, correct - I wrote that reply from my phone and didn't check the tests.

Thanks again, I'll try to release today.

@mrmckeb
Copy link
Owner

mrmckeb commented Jul 14, 2019

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