Answer the question
In order to leave comments, you need to log in
Webpack-dev-server or localhost infinite loading?
I set up a development environment for react, when I enter the npm start command, it throws me to localhost: 8080 and stupidly the page (not the browser) is endlessly loaded until it stops responding (and gives out "wow"). At first I thought the problem was in the port (changed it to another one), it didn’t help, then I thought the problem was in the hosts file, but everything is ok there ... it is noteworthy that the console in the browser does not give errors and the build occurs without errors. Operating system macos, before it worked on Windows and this did not happen. There is no logic in the files - accordingly, there are no timers or cycles that can stop the page from working.
webpack.config.js:
const htmlWebpackPlugin = require("html-webpack-plugin");
const path = require("path");
module.exports = {
devtool: "
entry: "./frontend/src/index.js",
output: {
path: path.resolve(__dirname + "/dist/"),
filename: "bundle.js"
},
module: {
rules: [
{
test: /\.(js|jsx)$/,
exclude: /node_modules/,
use: {
loader: "babel-loader"
}
},
{
test: /\.(css|scss)$/,
use: [
"style- loader",
"css-loader",
"postcss-loader",
"sass-loader"
]
}
]
},
plugins: [
new htmlWebpackPlugin({
template: "./frontend/public/index.html",
filename: "./index.html"
})
]
}
package.json:
{
"name": "random_app ",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"start": "webpack-dev-server --mode development -- hot --open",
"build": "webpack --mode production"
},
"author":"",
"license": "ISC",
"devDependencies": {
"@babel/core": "^7.1.2",
"@babel/preset-env": "^7.1.0",
"@babel/preset-react": "^7.0.0",
"autoprefixer": "^9.3.0",
"babel-loader": " ^8.0.4",
"css-loader": "^1.0.0",
"html-webpack-plugin": "^3.2.0",
"node-sass": "^4.9.4",
"postcss- loader": "^3.0.0",
"sass-loader": "^7.1.0",
"style-loader": "^0.23.1",
"webpack": "^4.22.0",
"webpack- cli": "^3.1.2",
"webpack-dev-server": "^3.2.1"
},
"dependencies": {
"react": "^16.5.2",
"react-dom": "^16.5.2",
"react-router-dom": "^5.0.0"
}
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question