I am trying to implement the material-components-webReact application correctly with Webpack 2. I want to import Sass files so that they can be thematic.
Here are what I think are relevant parts of my configuration:
var webpackConfig = module.exports = {
context: path.resolve(__dirname, '..'),
entry: {
'main': [
'./src/theme/main.scss',
'./src/client.js'
]
},
module: {
rules: [
{
test: /\.scss$/,
use: [
{
loader: 'style-loader',
}, {
loader: 'css-loader',
options: {
modules: true,
importLoaders: 3,
sourceMap: true,
localIdentName: '[local]___[hash:base64:5]'
}
}, {
loader: 'autoprefixer-loader',
options: {
browsers: 'last 2 version'
}
}, {
loader: 'resolve-url-loader',
}, {
loader: 'sass-loader',
options: {
outputStyle: 'expanded',
sourceMap: true,
includePaths: ['../src', '../node_modules', '../node_modules/@material/*']
.map(d => path.join(__dirname, d))
.map(g => glob.sync(g))
.reduce((a, c) => a.concat(c), [])
}
},
],
}
]
},
resolve: {
modules: [
'src',
'node_modules'
],
extensions: ['.json', '.js', '.jsx', '.scss']
}
};
and I ran main.scss with this:
$mdc-theme-primary:
$mdc-theme-accent:
$mdc-theme-background:
@import '~material-components-web/material-components-web.scss';
All my Sass files load normally, but the import material-components-webdoes not work at all, but also does not cause any errors.
If I add 'material-components-web/dist/material-components-web.min.css'in entry.main, then it will work, but then I obviously cannot easily change the subject so that it seems wrong. What should I do here?