Such a fun problem, I couldn't find any information on it. I want to make a template for react, but something doesn't work.

I created this structure:

Installed dependencies

"devDependencies": {
    "@babel/core": "^7.16.7",
    "@babel/preset-env": "^7.16.8",
    "@babel/preset-react": "^7.16.7",
    "babel-loader": "^8.2.3",
    "css-loader": "^6.4.0",
    "mini-css-extract-plugin": "^2.4.2",
    "webpack": "^5.66.0",
    "webpack-cli": "^4.9.1",
    "webpack-dev-server": "^4.3.1"
  "dependencies": {
    "react": "^17.0.2",
    "react-dom": "^17.0.2"

I have configured webpack.config.js

const path= require("path");
const MiniCssExtractPlugin= require("mini-css-extract-plugin");
let configWebPack= {
  entry: "./src/index.js",
  output: {
    path: path.resolve(__dirname, "./dist"),
    filename: "main.js",
    publicPath: "/dist/",
  devServer: {
    contentBase: __dirname + "/dist",
  module: {
    rules: [
        test: /\.js$/,
        loader: "babel-loader",
        exclude: /node_modules/,
        test: /\.css$/,
        use: [MiniCssExtractPlugin.loader, "css-loader"],
  plugins: [new MiniCssExtractPlugin({ filename: "main.css" })],
module.exports= (env, options)=> {
  let isProduction= options.mode=== "production";
  configWebPack.devtool= isProduction ? false : "eval-cheap-module-source-map";
  return configwebpack;

Written in json

"scripts": {
    "dev": "webpack serve --mode development",
    "build": "webpack --mode production"

There are only 2 instructions, transfer css and js of course with babel -tasks. By the way myselfpresets

  "presets": ["@babel/react"]

This works well, but running in development moderefuses to fetch the required data fromhtml

**Html structure**
<!DOCTYPE html><htmllang="en"><head>  <meta charset="UTF-8">  <meta http-equiv="X-UA-Compatible" content="IE=edge">  <meta name="viewport" content="width=device-width, initial-scale=1.0">  <title>Document</title></head><body>  <div id="root"></div></body><script src="./dist/main.js"></script></html>

On startupdevelopmentthere is a host along the wayport/dist/main.jsBut the page itself givesCannot GET /


Failed to load resource: the server responded with a status of 404 (Not Found)

I see myselfreactdoes its job, buthtmlhe does not see the page. What could be the problem?

Guys everything is so sad, no one can help?

WalkMess2022-01-16 07:51:08