How do we set the @material Sass folder include path scope ???
In this section: https://github.com/material-components/material-components-web#css there is a NOTE: "The components' Sass files expect that the node_modules directory containing the @material scope folder is present on the Sass include path." How is this done now in an Angular CLI project?
For my webpack setup personally, It was impossible to get @material working.
Here's what I had to do. Just import it all at one. :|
@import '~material-components-web/material-components-web';
And it depends on your build process. Webpack? Grunt? Gulp?
My build process is Webpack, but there's no access to the config as I'm using the AngularCli. I did originally try what you suggested but I got a bunch of other errors as there are also inter-package dependency which fail for the same reasons. :(
Not sure what to tell you if you don't have access to the webpack config. I added it to my sass include path like so: (webpack 2)
{
test: /\.(sass|scss)$/,
use: [
'style-loader',
'css-loader',
{
loader: 'sass-loader',
options: {
includePaths: [
'node_modules', 'bower_components', 'src', '.'
]
},
},
]
},
Hello,
In your .angular-cli.json you should add:
"apps": {
...
"stylePreprocessorOptions": {
"includePaths": [
"../node_modules"
]
},
...
}
Thank you @pierre-hilt simple if you know how! If only that were documented somewhere...
For anyone working with Grunt and Grunt-Sass.
sass: {
options: {
sourceMap: true,
relativeAssets: false,
outputStyle: 'compressed',
sassDir: 'css',
cssDir: 'css',
includePaths: [
'node_modules/'
]
},
build: {
files: [{
expand: true,
cwd: 'css/',
src: ['**/*.{scss,sass}'],
dest: 'css',
ext: '.min.css'
}]
}
},
And for Gulp? I am using Web Starter Kit and facing same issue.
@kminehart thank you so much!
Any updates for Gulp?
This is what worked in my setup;
- ./node_modules/material-components-web/node_modules
...
gulp.task('styles', function(){
gulp.src(sassFiles)
.pipe(sass({includePaths: ['./node_modules/material-components-web/node_modules'], outputStyle: 'compressed'}).on('error', sass.logError))
.pipe(gulp.dest(cssDest));
});
...
For Gulp see this link it works fine for me : https://github.com/material-components/material-components-web/issues/603#issuecomment-315523198
@pierre-hilt works like charm