鍍金池/ 問答/HTML/ dvajs 使用sass報(bào)錯(cuò)

dvajs 使用sass報(bào)錯(cuò)

在dvajs里面配置sass報(bào)錯(cuò)

webpackConfig.module.loaders.push({
  test: /\.module\.sass$/,
  loader: path.join(path.dirname(require.resolve('extract-text-webpack-plugin')), 'loader.js') + '?{"remove":true}!css?sourceMap&modules&localIdentName=[local]___[hash:base64:5]&-autoprefixer!' + 'postcss-loader!'+ 'sass-loader?sourceMap'
});
webpackConfig.module.loaders.forEach(function(loader, index) {
  if (typeof loader.test === 'function' && loader.test.toString().indexOf('\\.sass$') > -1) {
    loader.include = /node_modules/;
    loader.test = /\.sass$/;
  }
  if (loader.test.toString() === '/\\.module\\.sass$/') {
    loader.exclude = /node_modules/;
    loader.test = /\.sass$/;
  }
})

報(bào)錯(cuò)信息是:

 webpackConfig.module.loaders.push({
                               ^

TypeError: Cannot read property 'push' of undefined
回答
編輯回答
維她命

我改了配置不報(bào)錯(cuò) 但是引用sass文件還是說沒有配置報(bào)錯(cuò)

  webpackConfig.module.rules.push({
  test: /\.module\.sass$/,
  use: path.join(path.dirname(require.resolve('extract-text-webpack-plugin')), 'loader.js') + 'postcss-loader!'+ 'sass-loader'
});
webpackConfig.module.rules.forEach(function(use, index) {
  if (typeof use.test === 'function' && use.test.toString().indexOf('\\.sass$') > -1) {
    use.include = /node_modules/;
    use.test = /\.sass$/;
  }
  // if (use.test.toString() === '/\\.module\\.sass$/') {
  //   use.exclude = /node_modules/;
  //   use.test = /\.sass$/;
  // }
});

可以直接在roadhogrc 里面進(jìn)行布爾值的配置

2017年10月22日 15:00
編輯回答
吢涼

這個(gè)與sass沒關(guān)系呀。
webpackConfig.module中沒有定義loaders

webpack.config.js

module: {
   loaders: []
}
2018年3月14日 01:43