create-react-app和Sass似乎没有工作

时间:2017-06-02 02:57:32

标签: webpack sass create-react-app

我不确定,但几个月前这种情况完全正常,但现在,它似乎不再起作用了。使用React的create-react-app模块,更新webpack.config.dev.js以测试以下内容:

  {
    test: /\.(css|scss)$/,
    loader: 'style!css?importLoaders=1!postcss!sass'
  },

...对于依赖项node-sasssass-loader.scss样式似乎没有被捕获。

有什么想法吗?

1 个答案:

答案 0 :(得分:0)

我还需要更新webpack配置中的url加载程序以排除scss个文件

    exclude: [
      /\.html$/,
      // We have to write /\.(js|jsx)(\?.*)?$/ rather than just /\.(js|jsx)$/
      // because you might change the hot reloading server from the custom one
      // to Webpack's built-in webpack-dev-server/client?/, which would not
      // get properly excluded by /\.(js|jsx)$/ because of the query string.
      // Webpack 2 fixes this, but for now we include this hack.
      // https://github.com/facebookincubator/create-react-app/issues/1713
      /\.(js|jsx)(\?.*)?$/,
      /\.(css|scss)$/,
      /\.json$/,
      /\.svg$/
    ],
    loader: 'url',
    query: {
      limit: 10000,
      name: 'static/media/[name].[hash:8].[ext]'
    }
  },