Skip to content
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

Header/Footer: Modularize CSS files and process with PostCSS. #6

Merged
merged 3 commits into from
Sep 21, 2021

Conversation

iandunn
Copy link
Member

@iandunn iandunn commented Sep 15, 2021

while working on WordPress/wporg-news-2021#28, the single style.css file has become unwieldy, and at this point the the benefits of preprocessing now outweigh the pain of tooling IMO.

it's easier to separate the files before that PR is merged

PostCSS has most of the features of SASS, but is more future-proof.

The contents will soon become too much to keep in a single file, and it's easier to separate while it's still small. PostCSS has most of the features of SASS, but is more future-proof.
@iandunn iandunn added the [Type] Enhancement New feature or request label Sep 15, 2021
@iandunn iandunn self-assigned this Sep 15, 2021
@coreymckrill
Copy link
Contributor

What do you think makes PostCSS more future-proof? From a package dependency perspective, it looks like this PostCSS config has 8 dependencies, whereas the Sass setup in wporg-news-2021 has 2...

@iandunn
Copy link
Member Author

iandunn commented Sep 21, 2021

my understanding is that postcss is basically polyfilling future official css features, while sass is a custom thing.

e.g., w/ a sass plugin you can use variables inside media queries, but postcss instead supports custom media queries

also informed by this discussion: WordPress/gutenberg#14801 (comment)

@ryelle
Copy link
Contributor

ryelle commented Sep 21, 2021

passer-by comment: PostCSS is pretty minimal, and you only opt into the features you need, that's why there are more deps for a PostCSS config. Usually you can find PostCSS plugins following official spec proposals, so at some point when browsers support that spec, you could remove the plugin and everything will keep working.

If that's a feature you want, you'll need to check each plugin though - I see you've got postcss-nested, which follows how Sass does nesting, but isn't the spec version. The plugin using the actual spec format is postcss-nesting.

It's also fairly straightforward to write small PostCSS plugins (maybe? I've written a few at this point so I'm probably biased), which can be used as helpers to do things like cleanup, format values, etc. Definitely an edge case but it's come in handy before. Those can be in the same codebase as the config, and used without needing to release a npm plugin or anything.

@iandunn
Copy link
Member Author

iandunn commented Sep 21, 2021

great catch, switched to postcss-nesting in aca800f

Copy link
Contributor

@coreymckrill coreymckrill left a comment

Choose a reason for hiding this comment

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

Thanks, this all makes sense. 👍

At some point it might be worth migrating wporg-news-2021 to PostCSS also, though I don't think it would be a high priority right now.

@iandunn
Copy link
Member Author

iandunn commented Sep 21, 2021

agreed, i opened WordPress/wporg-parent-2021#1 to track that, but am ambivalent about when to do it

@iandunn iandunn merged commit 17f51fc into trunk Sep 21, 2021
@iandunn iandunn deleted the add-postcss branch September 21, 2021 22:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Type] Enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants