Hello,
I am having trouble importing Material Components for Web in Sage 9 using the included webpack.config.js.
My main.scss: @import "~@material/animation/mdc-animation";@import "~@material/button/mdc-bu - Pastebin.com
When I try to run yarn build
. I’m getting this error:
File to import not found or unreadable: @material/animation/mdc-animation.
The issue have already been documented using a similar setup as Sage 9 there:
https://github.com/material-components/material-components-web/issues/351
TLDR solution to fix this issue:
You need to make sure you include the path to the material modules in your sass-loader config
The problem is that I’m not able to implement the solution suggested in the link within Sage webpack.config.js. Throughout my google research, I have found a solution that work but only if I remove ${sourceMapQueryStr}
{
test: /\.scss$/,
include: config.paths.assets,
use: ExtractTextPlugin.extract({
fallback: 'style',
publicPath: '../',
use: [
`css?${sourceMapQueryStr}`,
'postcss',
`resolve-url?${sourceMapQueryStr}`,
`sass?&includePaths[]=${path.resolve(__dirname, '../../node_modules')}`,
],
}),
},
If I use this line instead:
sass?${sourceMapQueryStr}&includePaths[]=${path.resolve(__dirname, '../../node_modules')}
,`
I’m getting this error:
Error: Invalid mapping: {"generated":{"line":11440,"column":0},"source":"C:/www/project.dev/site/web/app/themes/sage/assets/styles/C:\\www\\project.dev\\site\\web\\app\\themes\\sage/assets\\styles\\node_modules\\@material\\theme\\_mixins.scss","original":{"line":94,"column":-1},"name":null}
My knowledge of NodeJS and Webpack is pretty limited since usually “it just works” so I think it’s as far as I’m going to get without external help.
If anyone with good understanding of what’s going on and what need to be done to properly import Material Components for Web using Sage 9 webpack.config.js could point me in the right direction, I’de appreciate the help.