-
Notifications
You must be signed in to change notification settings - Fork 15
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
Sass includePaths and Babel-resolved aliases #3
Comments
I don't completely understand your issue. It seems like you want to load a sass file from inside node_modules directory. If this was possible even without eyeglass would this fix your issue ? If so please have a look at #2 |
Yes, I know about normalize. There is also I just tried a relative path to one of the
There is also the babel-plugin-module-resolver that could help, I had it planned to try that today / tomorrow. Will let you know how it goes. So I could just import with ‘node_modules/…’ or ‘modules/…’ without knowing the relative distance. That’s pretty cool for other things too like ‘components’, etc. I doubt it will help in the case of sass modules though. And in any case there is a lot more to eyeglass than imports, and many sass modules on npm supporting it. From memory: there's also support for images, sprites, etc. I think it would be a very worthwhile addition, if someone could figure out how to plug it in... |
Something else: the failing |
A nice guy from const path = require('path')
const glob = require('glob')
//...
{ test: /\.s(a|c)ss$/,
use: [
'babel-loader', 'raw-loader', 'postcss-loader',
{ loader: 'sass-loader',
options: {
includePaths: glob.sync('node_modules').map((d) => path.join(__dirname, d))
}
}
]
}, |
For the record, here is my improved config: { loader: 'sass-loader',
options: {
includePaths: ['node_modules', 'node_modules/@material/*']
.map((d) => path.join(__dirname, d))
.map((g) => glob.sync(g))
.reduce((a, c) => a.concat(c), [])
}
} The example could come without the |
Interesting, could you work on a PR ? |
On this repo or |
i think so, yes |
Sure, I’d love to do my first PR on
I have at least one further improvement in mind regarding PostCSS. Let’s discuss / do that with a separate issue… |
The pull request I just made has one flaw that I can see - |
I will update things accordingly. |
@davibe not all the changes. About [
"module-resolver", {
"root": ["."],
"alias": {
"styles": "./styles"
},
"cwd": "babelrc"
}] I see you've got |
Here are the 2 pull requests, if you want to double-check that you copied everything over: |
@davibe I also got a link on the example's readme fixed with this PR to what I originally intended -- Deconfusing Pre- and Post-processing |
How can this be achieved in [email protected] without creating custom next.config.js? |
I can’t get eyeglass to work and that seems like the best way to load sass from node_modules. Perhaps the only way in some cases it seems (when reaching for a path inside a module is necessary). For example trying to load scss from material-components-web fails, very sad. I was hoping eyeglass could help with that and other things. There is an open issue that I just commented on. Also tried the
webpack-combine-loaders
from the example @wesm87 has there which didn’t help. Any ideas about how to get this working? Look like a very worthwhile addition / a best practice?The text was updated successfully, but these errors were encountered: