安装 npm install concurrently --save-dev

"concurrently": "^7.3.0",

concurrently支持开启多个服务,如下示例中执行npm run dev或者npm run all,则可以同时执行多个npm运行指令。

"scripts": {
    "build": "vue-cli-service build",
    "serve": "vue-cli-service serve",
    "lint": "vue-cli-service lint",
    "report": "vue-cli-service build --report",
    "koa": "node ./koa/abs.js",
    "dev": "concurrently \"npm run koa\" \"npm run serve\""
},
或
"scripts": {
    "dev": "node app.js",
    "start": "node index.js",
    "all": "concurrently \"npm run dev\" \"npm start\""
},

支持多个打包程序服务一起进行的方式,使用&& 合并多个npm运行命令,执行 npm run build:all则得到lib-index和lib-login两个打包文件。

"scripts": {
    "dev": "vue-cli-service serve",
    "build": "vue-cli-service build",  
    "lib": "vue-cli-service build --target lib --name lib-index --dest lib-index ./src/index.js",
    "lib:login": "vue-cli-service build --target lib --name lib-login --dest lib-login ./src/login.js",
    "build:all": "npm run lib && npm run lib:login",
},
posted on 2022-11-09 17:28  羽丫头不乖  阅读(229)  评论(0编辑  收藏  举报