webpack如何设置是否自动开启浏览器

当我们执行npm run dev命令的时候,我们想要自动开启浏览器,那么只需要在webpack-dev-server后面加上”–open”参数,具体在package.json文件里面设置,配置文件内容如下:

{
  "name": "webpack-demo1",
  "version": "1.0.0",
  "main": "main.js",
  "scripts": {
    "dev": "webpack-dev-server --open",
    "build": "webpack -p"
  },
  "license": "MIT"
}