【问题标题】:create-react-app and Sass don't appear to be workingcreate-react-app 和 Sass 似乎没有工作
【发布时间】:2017-06-02 02:57:31
【问题描述】:

我不确定,但几个月前它工作得非常好,但现在,它似乎不再工作了。使用 React 的 create-react-app 模块,更新 webpack.config.dev.js 以测试以下内容:

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

...由于依赖关系 node-sasssass-loader.scss 样式似乎没有被捕获。

有什么想法吗?

【问题讨论】:

    标签: webpack sass create-react-app


    【解决方案1】:

    我还需要更新 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]'
        }
      },
    

    【讨论】:

      猜你喜欢
      • 2022-08-16
      • 2019-04-19
      • 1970-01-01
      • 2018-09-16
      • 2019-04-26
      • 2013-11-25
      • 2017-08-26
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多