Z
Z
zaicev992021-07-19 12:32:01
webpack
zaicev99, 2021-07-19 12:32:01

Webpack does not update page content when building, how to fix?

I have the following project:
package.json:

{
  "name": "frontend",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "dev": "webpack --mode development ./src/index.js --output-path ./static/frontend/",
    "build": "webpack --mode production ./src/index.js --output-path ./static/frontend/"
  },
  "keywords": [],
  "author": "",
  "license": "ISC",
  "devDependencies": {
    "@babel/core": "^7.14.6",
    "@babel/preset-env": "^7.14.7",
    "@babel/preset-react": "^7.14.5",
    "babel-loader": "^8.2.2",
    "react": "^17.0.2",
    "react-dom": "^17.0.2",
    "webpack": "^5.44.0",
    "webpack-cli": "^4.7.2"
  },
  "dependencies": {
    "axios": "^0.21.1"
  }
}


webpack.config.js
{
  "name": "frontend",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "dev": "webpack --mode development ./src/index.js --output-path ./static/frontend/",
    "build": "webpack --mode production ./src/index.js --output-path ./static/frontend/"
  },
  "keywords": [],
  "author": "",
  "license": "ISC",
  "devDependencies": {
    "@babel/core": "^7.14.6",
    "@babel/preset-env": "^7.14.7",
    "@babel/preset-react": "^7.14.5",
    "babel-loader": "^8.2.2",
    "react": "^17.0.2",
    "react-dom": "^17.0.2",
    "webpack": "^5.44.0",
    "webpack-cli": "^4.7.2"
  },
  "dependencies": {
    "axios": "^0.21.1"
  }
}


When you run the npm run dev command, the updates are collected in the main.js file.
But when you restart the server, no changes are visible on the page, as if it were loading the old file (I tried to delete it manually - anyway)
Tell me what to do?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question