Skip to content

Conversation

@dagda1
Copy link
Contributor

@dagda1 dagda1 commented Nov 9, 2019

I finally got the bottom of making this work with my monorepo with external sass options in node_modules.

I first mentioned this in #37.

I've added node_modules to the includedPaths for sass by default.

const includePaths = [filePath, 'node_modules'];

I also encountered a bug on my travels with this code:

transformedCss = sass
  .renderSync({
    data: css,
    includePaths: [filePath],
    ...(rendererOptions.sass || {}),
  })
.css.toString();

It if you were passing in includePaths in the sass options like this:

{
  rendererOptions: {
   sass: { includePaths: ["node_modules"] }
  }
},

Then it was overwriting the original includePaths: [filePath], you can see an example here

const filePath = '/src/helpers/__tests__/fixtures';
const css = 'blah';
const rendererOptions = {
    sass: { includePaths: ["node_modules"] }
}

const result = {
    data: css,
    includePaths: [filePath],
    ...(rendererOptions.sass || {}),
}

console.log(JSON.stringify(result.includePaths));  // [node_modules] and not ['/src/helpers/__tests__/fixtures', 'node_modules']

I'm not sure if you agree with adding node_modules by default and I will remove it if needs be.

@mrmckeb mrmckeb added this to the v2.1.0 milestone Nov 11, 2019
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.

This looks great, thanks @dagda1. A few minor suggested changes, if you can't make them, I can do it this weekend :)

@dagda1 dagda1 requested a review from mrmckeb November 14, 2019 21:22
@dagda1 dagda1 changed the base branch from master to develop November 16, 2019 13:22
@dagda1
Copy link
Contributor Author

dagda1 commented Nov 16, 2019

@mrmckeb Are these changes better?

sorry to be annoying but I am dying to get this rolled into my personal projects.

@mrmckeb mrmckeb assigned mrmckeb and unassigned mrmckeb Nov 17, 2019
@mrmckeb mrmckeb merged commit c350ce7 into mrmckeb:develop Nov 17, 2019
@mrmckeb
Copy link
Owner

mrmckeb commented Nov 17, 2019

Hi @dagda1, I'll try to do a release tonight or tomorrow - sorry for the slow reply.

You're not annoying, I'm just slow (busy few days) ;)

@dagda1 dagda1 deleted the master branch November 17, 2019 13:54
@dagda1 dagda1 restored the master branch November 17, 2019 22:22
@mrmckeb
Copy link
Owner

mrmckeb commented Nov 18, 2019

Released as https://github.com/mrmckeb/typescript-plugin-css-modules/releases/tag/v2.1.0.

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