Skip to content

Load PostCSS config #33

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 8 commits into from
Sep 7, 2019
Merged

Conversation

hipstersmoothie
Copy link
Contributor

My postcss config uses a plugin that adds some classnames for themes. This PR will load a postcss config if there is on and use it to transform the CSS

@mrmckeb
Copy link
Owner

mrmckeb commented Jul 30, 2019

Thanks @hipstersmoothie, I'll take a look at this tomorrow hopefully and either merge or provide feedback then!

@mrmckeb mrmckeb requested review from mrmckeb and lianapache July 30, 2019 18:45
@mrmckeb
Copy link
Owner

mrmckeb commented Aug 1, 2019

Sorry, this is still on my to do list. It'll be done by the end of the weekend for certain.

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.

Hi @hipstersmoothie, are you able to provide any test files for this?

If you don't have time, I can finish this off and get it released :)

removePlugin(),
...postcssConfig.plugins.filter(
// Postcss mixins plugin might be async and will break the postcss sync output.
(plugin) => !['postcss-mixins'].includes(plugin.postcssPlugin),
Copy link
Owner

Choose a reason for hiding this comment

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

Maybe it's better to just add a note to the docs here? As the plugin (from what I read) is only async when files are passed in.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yup! If we don't remove it for them we would have to pass something like env: editor to accommodate. If the mixins aren't filtered and they are async, the plugin just doesn't work.

import { createMatchers } from './helpers/createMatchers';
import { isCSSFn } from './helpers/cssExtensions';
import { getDtsSnapshot } from './helpers/cssSnapshots';
import { Options } from './options';

import * as postcss from 'postcss';
Copy link
Owner

Choose a reason for hiding this comment

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

We load this in cssSnapshots.ts. Was there a reason you decided to load a processor here as well?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I decided to move the instantiation of the postcss processor here because it would:

  • only be done once
  • I needed access for to info to call info.project.getCurrentDirectory() and didn't want to pass new params into cssSnapshots.ts

function create(info: ts.server.PluginCreateInfo) {
const postcssConfig = getPostCssConfig(info.project.getCurrentDirectory());
Copy link
Owner

Choose a reason for hiding this comment

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

This tool looks great, but I see it's not official - so I should probably add that to the docs. What do you think?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm not sure that's true. You can see that they use this package in postcss-cli here https://github.com/postcss/postcss-cli/blob/master/index.js#L14

@mrmckeb mrmckeb added this to the 1.3.0 milestone Aug 16, 2019
@mrmckeb mrmckeb changed the title Load postcss config Load PostCSS config Aug 18, 2019
@mrmckeb
Copy link
Owner

mrmckeb commented Aug 26, 2019

Hi @hipstersmoothie, unfortunately I'm away until Sunday - it's been a crazy month. I'll get this out as a beta so that you can work and release a minor version when I get back - as I want to update a few things.

@mrmckeb
Copy link
Owner

mrmckeb commented Aug 26, 2019

OK, unfortunately the rebase on this requires a bit of work. I can take a look later today or tomorrow - sorry about the delay here.

@hipstersmoothie
Copy link
Contributor Author

@mrmckeb took care of merging develop into my branch again 🚀

@hipstersmoothie
Copy link
Contributor Author

I've open postcss/postcss-mixins#96 to help with the mixins issue. I will be removing the lines that remove the plugin since this can break parsing if we remove it

@mrmckeb
Copy link
Owner

mrmckeb commented Sep 7, 2019

Thanks @hipstersmoothie, I've merged this and will release a new beta very soon. I'm travelling tomorrow and plan to use my airport time to polish this up and create a release.

@mrmckeb mrmckeb merged commit 7033534 into mrmckeb:develop Sep 7, 2019
@hipstersmoothie hipstersmoothie deleted the load-config branch September 9, 2019 23:28
@mrmckeb
Copy link
Owner

mrmckeb commented Sep 18, 2019

This is now in 1.3.1 (out of beta). Thanks again!

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