IMAGE: You may need an appropriate loader to handle this file type

后端 未结 4 1309
温柔的废话
温柔的废话 2020-12-05 17:45

I can\'t figure what is the proper loader to load images in ReactJS webpack,

May you give me a hand? I get this error:

Module parse failed: /Users/im         


        
4条回答
  •  醉话见心
    2020-12-05 18:23

    You can use file-loader. You need to install it first using npm and then edit your webpack config like this

    module: {
    
        // apply loaders to files that meet given conditions
        loaders: [{
          test: /\.jsx?$/,
          include: path.join(__dirname, '/client/src'),
          loader: 'babel-loader',
          query: {
            presets: ["react", "es2015", "stage-1"]
          }
        },
        {
          test: /\.(gif|svg|jpg|png)$/,
          loader: "file-loader",
        }],
      },
    

提交回复
热议问题