Skip to content

Support for extra postcss plugins #100

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 9 commits into from
Jun 18, 2017
Merged

Conversation

mvsmal
Copy link
Contributor

@mvsmal mvsmal commented Jun 12, 2017

Added support for extra postcss plugins. They can be specified in "filetypes" section of config like this:

"filetypes": {
  ".scss": {
    "syntax": "postcss-scss",
    "plugins": ["postcss-nested"]
  }
}

Copy link
Owner

@gajus gajus left a comment

Choose a reason for hiding this comment

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

Looks good. Thank you.

Made just a few small change requests.

Please also add a note to the commit saying that it is a "BREAKING CHANGE:" to trigger the major version bump.

const getTokens = (runner, cssSourceFilePath: string, filetypes): StyleModuleMapType => {
type FileTypeOptions = {|
syntax: string,
plugins: Array<string>
Copy link
Owner

Choose a reason for hiding this comment

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

Please use $ReadOnlyArray and covariant props, i.e. {|+syntax: string, plugins: $ReadOnlyArray<string>|}

plugins: Array<string>
|};

const getFiletypeOptions = (cssSourceFilePath: string, filetypes: Object): ?(string|FileTypeOptions) => {
Copy link
Owner

Choose a reason for hiding this comment

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

filetypes type needs to be {[key: string]: FileTypeOptions}

Copy link
Owner

Choose a reason for hiding this comment

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

?(string|FileTypeOptions) does not match the return type (not getting an error here?) FileTypeOptions | string | null.

Where does the string come from, though?

Copy link
Owner

Choose a reason for hiding this comment

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

Where does the string come from, though?

I see.

Lets remove the shortcut. This is going to be a breaking change.

Require that FileTypeOptions is always present.

return filetype;
};

const getSyntax = (filetypeOptions: ?(string|FileTypeOptions)) => {
Copy link
Owner

Choose a reason for hiding this comment

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

Require that filetypeOptions is always FileTypeOptions. Do not call getSyntax if filetypeOptions option is void.

return null;
};

const getExtraPlugins = (filetypeOptions: ?(string|FileTypeOptions)): Array<any> => {
Copy link
Owner

Choose a reason for hiding this comment

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

Use $ReadOnlyArray

return filetype;
};

const getSyntax = (filetypeOptions: ?(string|FileTypeOptions)) => {
Copy link
Owner

Choose a reason for hiding this comment

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

Declare the return type annotation for getSyntax.

@@ -5,7 +5,9 @@
{
"generateScopedName": "[name]__[local]",
"filetypes": {
".less": "postcss-less"
".less": {
"syntax": "postcss-less"
Copy link
Owner

Choose a reason for hiding this comment

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

This is using the old syntax.

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've changed it to Object { "syntax": "..." }. Sorry, what's wrong?

Copy link
Owner

Choose a reason for hiding this comment

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

Oops. Sorry. This PR was the first thing I looked at this morning. :-)

@mvsmal
Copy link
Contributor Author

mvsmal commented Jun 18, 2017

So. What's next? I've updated the code according to your requests.

@gajus gajus merged commit b3f53f5 into gajus:master Jun 18, 2017
@gajus
Copy link
Owner

gajus commented Jun 18, 2017

So. What's next? I've updated the code according to your requests.

Sorry, overloaded at work. Merged.

Thank you,

@Nantris
Copy link

Nantris commented Feb 15, 2018

Is there any way to set options on the plugins loaded this way?

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.

3 participants