Closed tim-steele closed 6 years ago
Here is an actual example of code I have that is breaking without this:
@import 'node_modules/sassfp/SassFP.scss';
@import './variables';
@import './properties';
Thanks for this!
I did not consider the case of importing from a top level folder, so I think that this fix will be useful.
Excellent. Thanks @kristerkari! Let me know when you have this merged in and a new version published so I can pull it in to our project.
I was looking at stack overflow and thinking that would it be better to do this to avoid the dependency?
var path = require('path');
var appDir = path.dirname(require.main.filename);
That stack overflow answer says that it should work for almost all cases.
What do you think about that @tim-steele?
Ha! Yes. I was reading the same answer. If you scroll down you will see the app-root-path method he talks about, and the module he built to try and handle all the situations as a sum of all of these. Let me know if you want me to use the one as I can make the change, or if you are fine using that person's node_module.
Using require.main.filename
might be enough, as the description says:
This will work great most of the time, but if you're running your app with a launcher like pm2 or running mocha tests, this method will fail.
We are not running the code in any test environment or with pm2, so it should work. If it doesn't, we can change back to the app-root-path
module :)
Sounds good @kristerkari. I updated the PR.
Great!
released as version 1.1.2
If I have a module in
node_modules
folder with a .scss extension that live inside of a name space, I am unable to reliably reference another node module in thenode_modules
folder without the root application directory being including in the search for imports.Example: