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

Loading transient sass modules through npm #227

Closed
eastwood opened this issue Mar 24, 2016 · 5 comments
Closed

Loading transient sass modules through npm #227

eastwood opened this issue Mar 24, 2016 · 5 comments

Comments

@eastwood
Copy link
Contributor

Hey guys,
Firstly, really loving the project, very easy to setup and get started. I have an interesting problem that I"m trying to solve, which involves transiently trying to resolve scss files from node_modules. Let's say for example we have:

test-project/
├── app
│   └── index.scss
└── node_modules
    ├── bar
    │   └── colors.scss
    └── foo
        └── variables.scss

In index.scss we want to do the following:

@import "~bar/colors"
body {
  background-color: $red;
}

Subsequently, colors.scss is importing stuff from the variables.scss

@import "foo/variables"
$red: $some_variable;

It's a pretty silly example, but outlines the fact that some legacy code requires the importing of other modules. When I resolve the index.scss, it manages to find the colors.scss file, but because the path of colors.scss is foo/variables and not ~foo/variables, it cannot find the module.

Is this something, where I'd have to modify the colors.scss file manually, or is there some webpack configuration or node-sass configuration I can do that will be able to resolve the `@import 'foo/variables' from the node_module?

It's probably worth mentioning that I'm not doing anything special in the webpack.config.js. Relative to the above example it's just a basic style!css!sass!index.scss

Thanks guys :)

@jameslnewell
Copy link

jameslnewell commented May 4, 2016

I think using a custom importer and #234 would allow you to work around this issue

@jhnns
Copy link
Member

jhnns commented Jun 26, 2016

I think it makes sense to add the node_modules folder to node-sass' includePath option. After that, this code should work.

@jcteague
Copy link

jcteague commented Nov 17, 2016

I'm having a similar problem. I'm importing a scss file from an installed npm node module. The imported file, in turn, has an import with coming from a node module but has the syntax
@import 'plugin'
sass loader is choking on the secondary import statement.

I've tried adding node_modules to the includePath and using

@alexander-akait
Copy link
Member

/cc @jhnns To be honest, I do not even represent a better solution than own importer for these projects, but maybe your have idea about this. Or we can just add example of such simple importer to README.

@alexander-akait
Copy link
Member

Seems duplicate #466. Feel free to reopen if it is different problem. Fast solution as said jhnns #227 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants