找不到模块:错误:无法解析' file'或者'目录' (加载scss文件)

时间:2016-12-07 12:03:31

标签: reactjs sass webpack loader

我收到了一些webpack错误

   ./src/js/containers/App.js中的错误   找不到模块:错误:无法解析' file'或者'目录' /用户/ chunza2542 /桌面/ odnpoll / src目录/ JS /容器    @ ./src/js/containers/App.js 13:11-32

我尝试安装resolve-url-loader NPM包。我配置webpack.config.js但我又遇到了同样的错误。

这是我的webpack.config.js



var debug = process.env.NODE_ENV !== "production";
var webpack = require('webpack');
var path = require('path');

module.exports = {
  devtool: debug ? "inline-sourcemap" : null,
  entry: "./src/js/main.js",
  module: {
    loaders: [
      {
        test: /\.js?$/,
        exclude: /(node_modules|bower_components)/,
        loader: 'babel-loader',
        query: {
          presets: ['react', 'es2015', 'stage-0']
        }
      },
      {
        test: /\.css?$/,
        loaders: ['style-loader', 'css-loader', 'resolve-url']
      },
      {
        test: /\.scss?$/,
        exclude: /node_modules/,
        loaders: [
          'style-loader',
          {
            loader: 'css-loader',
            query: {
              sourcemap: true,
              module: true,
              localIdentName: '[local]___[hash:base64:5]'
            }
          },
          {
            loader: 'sass-loader',
            query: {
              outputStyle: 'expanded',
              sourcemap: true
            }
          },
          'resolve-url'
        ]
      }
    ]
  },
  output: {
    path: __dirname + "/src/",
    filename: "client.min.js"
  },
  plugins: debug ? [] : [
    new webpack.optimize.DedupePlugin(),
    new webpack.optimize.OccurenceOrderPlugin(),
    new webpack.optimize.UglifyJsPlugin({ mangle: false, sourcemap: false }),
  ],
  devServer:{
    historyApiFallback: true
  }
};




感谢您的帮助。

修改

你可以看到我的代码&此链接中的文件目录 https://s24.postimg.org/dbk1txd05/Screen_Shot_2016_12_07_at_7_39_05_PM.png

0 个答案:

没有答案