'I am unable to load my landing page back ground image and other images on my page

This is a react-django app where I have set a background image but it is not loading on the web page at first it was working perfectly fine but now i am stuck at this point

This is the error which I get on the console:

Failed to load resource: the                :http://127.0.0.1:8000/favicon.ico
server responded with a status of 404 (Not Found) 

I have downloade three loaders to load my image. The loaders are image-webpack-loader, file-loader and url-loader. I configured one of it in my webpack.config.js file but still it didn't work. Below is my webpack.config.js file code :

const path = require("path");
const webpack = require("webpack");

module.exports = {
  entry: "./src/index.js",
  output: {
    path: path.resolve(__dirname, "./static/frontend"),
    filename: "[name].js",
  },
  module: {
    rules: [
      {
        test: /\.js$/,
        exclude: /node_modules/,
        use: {
          loader: "babel-loader",
        },
      },
      //additional configuration to handle *.ccs files
      {
        test: /\.css$/i,
        use: ["style-loader", "css-loader"],
      },
      {
        test: /\.(png|jpg|jpeg|gif|svg|eot|ttf|woff|woff2)$/,
        loader: "url-loader",
        options: {
          limit: 10000,
        },
      },
      {
        test: /\.json$/,
        use: [
          {
            loader: "file-loader",
            options: {
              name: "data/[name].[ext]",
            },
          },
        ],
      },//end loader
    ],
  },
  optimization: {
    minimize: true,
  },
  plugins: [
    new webpack.DefinePlugin({
      "process.env": {
        // This has effect on the react lib size
        NODE_ENV: JSON.stringify("production"),
      },
    }),
  ],
};

this is my Homepg.css file code where I have added the image:

#Homepgbtn1{
    position: absolute;
    align-items: center;
    left: 50%;
    right: 50%;
    top: 50%;
    bottom: 50%;
}
#Homepgbtn2{
    position: absolute;
    align-items: center;
    left: 48.5%;
    right: 50%;
    top: 57%;
    bottom: 50%;
    white-space: nowrap;
}
body{
    background-repeat: no-repeat;
    background-position: center center;
    background-attachment: fixed;
    background-size: cover;
    background-color: dimgrey;
    /*background-image:url("C:\Users\Kuldeep P\Desktop\RAMAN\GymWebsite\frontend\src\components\public\Sergi2.jpeg");*/
}

This is my component code for which I have specified the css file:

import ReactDom from "react-dom";
import Navbar from "./Navbar";
import React, { Component } from "react";
import "./css/Homepage.css";
//import insta from "./images/insta.png";

export default class HomePage extends Component {
  constructor(props) {
    super(props);
  }

  render() {
    return (
      <body className="img-fluid">
        <Navbar />
        <div id="mainDiv" className="container mainbtns text-center">
          <span id="Homepgbtn1">
            <button type="button" class="btn btn-success btn-lg ">
              Plans
            </button>
          </span>
          <span id="Homepgbtn2" className="my-3 ">
            <button type="button" class="btn btn-success btn-lg">
              Get Started
            </button>
          </span>
        </div>
        <div id="rbdiv">
          <span>
            {/*<img id="img1" src={insta} alt="Instagram"/>*/}
          </span>
          <button type="button" class="btn btn-light">
            Twitter
          </button>
          <button type="button" class="btn btn-light">
            Youtube
          </button>
        </div>
      </body>
    );
  }
}

Please help guys... tell me what changes I should do to my code to resolve the error



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source