Skip to content

Allow passing options to SCSS/Less render functions #54

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
Oct 20, 2019

Conversation

p7g
Copy link
Contributor

@p7g p7g commented Oct 20, 2019

This PR allows the user to pass options to the render function called for less or scss files.

My use-case for this is passing the paths option to the less configuration like this:

{
  "compilerOptions": {
    "plugins": [
      {
        "name": "typescript-plugin-css-modules",
        "options": {
          "renderOptions": {
            "less": {
              "paths": ["src/"]
            }
          }
        }
      }
    ]
  }
}

This allows me to use path aliases in my webpack config and match those in the less configuration to fix the import errors that occur because of said aliases.

In addition to that, I added some improvements to the error handling for when less fails to render the file. Previously, there would be an error like Cannot read property 'css' of undefined since the output is not passed into the callback if there was an error (I have made a PR to reflect this in the typings: DefinitelyTyped/DefinitelyTyped#39261).

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 @p7g, thanks for this PR - I was doing the same work yesterday, so there will be a few conflicts, but I'll work those out.

I'll try to merge this in and get this out today.

@mrmckeb mrmckeb closed this Oct 20, 2019
@mrmckeb
Copy link
Owner

mrmckeb commented Oct 20, 2019

Restarting the CI.

@mrmckeb mrmckeb reopened this Oct 20, 2019
@mrmckeb mrmckeb merged commit 14e7063 into mrmckeb:develop Oct 20, 2019
@mrmckeb
Copy link
Owner

mrmckeb commented Oct 20, 2019

Hi @p7g, we've just released v2.0.0 which includes this PR and other changes.

Release notes and migration steps can be found here: https://github.com/mrmckeb/typescript-plugin-css-modules/releases/tag/v2.0.0

Please let me know if you have any other issues or feedback! And thanks for your patience.

@p7g
Copy link
Contributor Author

p7g commented Oct 21, 2019

That’s awesome, thanks for all the hard work!

@mrmckeb
Copy link
Owner

mrmckeb commented Oct 21, 2019

No problem, very sorry about the long delays.

PS, I named it rendererOptions - but otherwise it's the same ;) Thanks for your help! You literally finished work I'd half completed the day before, so it was very helpful.

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