如何使用webpack-dev-server运行react应用程序?

时间:2019-02-14 10:56:36

标签: reactjs webpack-dev-server webpack-4

当我运行命令webpack-dev-server --open --mode development时,我得到的输出如图所示。我不知道该怎么办?我已经在这里呆了几个小时了。 但是,当我使用以下命令webpack --mode production准备建筑物并从dist文件夹中打开index.html文件时,它在浏览器中运行良好。

when I run the command webpack-dev-server --open --mode development, I get the output as shown in the image

我的package.json文件

{
    "name": "rapp",
    "version": "1.0.0",
    "description": "react app",
    "main": "index.js",
    "scripts": {
        "start": "npm run build",
        "build": "webpack-dev-server --open --mode development",
        "build:prod": "webpack --mode production"
    },
    "keywords": [
        "learning",
        "react"
    ],
    "author": "Rafay Hassan",
    "license": "MIT",
    "dependencies": {
        "babel-core": "^6.26.3",
        "babel-preset-env": "^1.7.0",
        "babel-preset-react": "^6.24.1",
        "react": "^16.8.1",
        "react-dom": "^16.8.1"
    },
    "devDependencies": {
        "babel-loader": "^7.*",
        "html-loader": "^0.5.5",
        "html-webpack-plugin": "3.0.7",
        "webpack": "^4.29.3",
        "webpack-cli": "^3.2.3",
        "webpack-dev-server": "^3.1.14"
    }
}

0 个答案:

没有答案