-
-
Notifications
You must be signed in to change notification settings - Fork 430
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
Importing sheets with dependencies on other npm packages #466
Comments
Have the same issue |
|
@marekpw @Yizhachok @borela can your provide minimal reproducible test repo? |
@evilebottnawi sure, here you go: https://github.com/marekpw/sass-loader-mdc/ As expected, prefixing the first import with tilde in |
@marekpw got it, you need to add const { dirname, join, resolve } = require('path');
const webpack = require('webpack');
module.exports = {
context: resolve('src'),
entry: {
app: './main.scss'
},
output: {
filename: '[name].[hash].js',
path: resolve('dist')
},
resolve: {
extensions: ['.js', '.scss']
},
module: {
rules: [
{
test: /\.scss$/,
use: [{
loader: "style-loader" // creates style nodes from JS strings
}, {
loader: "css-loader" // translates CSS into CommonJS
}, {
loader: "sass-loader", // compiles Sass to CSS
options: {
includePaths: [
join(dirname(module.filename), 'node_modules')
]
}
}]
}
],
}
}; Here's a full package for compiling websites in you case you need hot reloading too. |
Cool, that works. Thanks a lot. |
@evilebottnawi What's the other option? |
@evilebottnawi I believe this bug was introduced before then, I had been using the It did seam counter intuitive to me to have to duplicate the paths from webpack's |
@borela I will try to solve this problem today or tomorrow, thanks! |
@evilebottnawi Thank you, I wish I could offer better help but I am still learning how webpack loaders work. |
@borela as a workaround, it's still better than nothing for now :) |
Seems problems in |
/cc @michael-ciniawsky what do your think about problems? It's hard for me to imagine a solution for her, we can't add |
Besides the https://www.npmjs.com/package/sass-graph https://www.npmjs.com/package/sass-module-importer Or writing our own :) |
@michael-ciniawsky yep, this is known, the question is whether we at the level |
It will require changes to |
What do you exactly mean by fix ? 😛 |
@michael-ciniawsky no new loader or something other stuff (options), just change logic in sass-loader which allow loading scoped importing in vendor sass/scss styles |
If possible we should do it :), I'm not too familiar with |
I'm also experiencing this issue. I am trying to use
If I change the Here is my webpack sass-loader config:
Additionally, I know I can import styles without other dependancies from |
@ddobson workaround, but it is increase build time, no solution for this right now, but PR welcome |
Same problem here, I opened an issue with material components but looks like the issue is actually here. |
@mischkl old and known issue, solutions #479 (comment) |
@evilebottnawi @jhnns So basically anyone who wants to use the material components with webpack needs to build in this hack? Seems kind of like a poor solution. What we really need IMHO is for sass-loader to process imports that occur within third-party modules differently than those that occur in the webpack project itself. For reference, everything that https://github.com/sass-eyeglass/eyeglass supports should ideally be able to be resolved by sass-loader, for the purpose of long-term interoperability of the third-party scss module ecosystem. |
@mischkl it is not hack, it is correct solution. I agree we need search build-in solution for this, but it is not easy. Any ideas? PR welcome 👍 |
@evilebottnawi well, my idea is stated right there: process |
@mischkl it is breaking changes and can lead to a problem with performance and incompatibility, before think about this we should look how working |
@evilebottnawi you seem to be correct as judging by this issue: sass/node-sass#1596 As stated there the solution is to "use eyeglass". Which appears to be something like webpack, just limited to SCSS support... In any case it seems eyeglass does support importing scoped packages without a The odd thing is that |
@mischkl maybe this solution is right, it is really not easy to fix and i don't have ideas about this, but i am glad to hear any opinion and solution. Maybe we can fix this in |
@mischkl in theory any |
Say I have a project that deps two packages:
And say
// nested-styles/index.scss
@import "package-A/sass/index.scss";
body {
background: $background;
} where // node_modules/package-A/sass/index.scss
@import "package-B/sass/index.scss"; The following is my module.exports = {
entry: './index.js', // imports nested-styles/index.scss
output: {
filename: 'output.js',
},
module: {
rules: [{
test: /\.scss$/,
use: ['style-loader', 'css-loader', {
loader: 'sass-loader',
options: {
includePaths: ['node_modules'],
},
}],
}],
},
}; I'd like to get |
@adityavohra7 This sound like how node-sass works, any chance you can try to reproduce the exact behavior without using webpack, but by compiling ur sass using You probably need something like:
More info on how to use |
@frederikprijck, I've created a repo to repro the behavior I'm seeing. I also tried compiling my sass directly with // index.scss
@import "package-A/scss/index.scss";
body {
background: $background;
} // node_modules/package-A/scss/index.scss
@import "package-B/scss/index.scss"; // node_modules/package-B/scss/index.scss
$background: blue; // node_modules/package-A/node_modules/package-B/scss/index.scss
$background: pink; Calling
I'd like for that ^ to be "pink" ( |
@adityavohra7 So this looks like it's how node-sass is handling Probably a good idea to open an issue on node-sass to get more information from them. |
I'm having an issue that I think is related where I try to `@import 'material-design-colors/material-colors' this package and I get the following error from webpack:
Is this a related issue, or something else? I'm trying to |
Sorry but we can not do anything here. So |
@borela But I found very simple solution for @Material library - you must install components with same version. |
I'm trying to import the @material/button library like this:
@import "~@material/button/mdc-button";
However the mdc-button tries to import from another library:
@import "@material/animation/variables";
Webpack/sass-loader understandably complains that the file is not found, because it's not prefixed with a tilde.
Is there any workaround/fix to this issue?
The text was updated successfully, but these errors were encountered: