Material-web-component scss build

时间:2018-01-16 20:42:32

标签: webpack web-component

我对webpack相当新,但我不确定这是否是配置问题。我的构建失败是因为我的scss中的错误,或者(material-web-compenents本身)。当我尝试构建webpack时会抛出此错误:

ERROR in ./node_modules/css-loader!./node_modules/sass-loader/lib/loader.js!./client/styles.scss
Module build failed:
undefined
                                             ^
      Argument `$color` of `red($color)` must be a color

我的配置文件:

/*
    ./webpack.config.js
*/
const path = require('path');

const HtmlWebpackPlugin = require('html-webpack-plugin');
const HtmlWebpackPluginConfig = new HtmlWebpackPlugin({
  template: './client/index.html',
  filename: 'index.html',
  inject: 'body'
})

module.exports = {
  entry: './client/index.js',
  plugins: [HtmlWebpackPluginConfig],
  output: {
    path: path.resolve('dist'),
    filename: 'index_bundle.js'
  },
  module: {
    loaders: [
      { test: /\.js$/, loader: 'babel-loader', exclude: /node_modules/ },
      { test: /\.jsx$/, loader: 'babel-loader', exclude: /node_modules/ },
      {
          test: /\.scss$/,
          loaders: ["style-loader", "css-loader", "sass-loader"]
      }]
  }
}

如果我删除所有变量,它将构建。堆栈跟踪显示它源自mdc组件。 SCSS文件:

$mdc-theme-primary: #37474F !default;
$mdc-theme-primary-light: mdc-theme-light-variant($mdc-theme-primary) !default;
$mdc-theme-primary-dark: mdc-theme-dark-variant($mdc-theme-primary) !default;
$mdc-theme-secondary: #B0BEC5 !default;

@import "~@material/theme/mdc-theme";

0 个答案:

没有答案