パッケージ.json
{
"name": "micro-web-project",
"version": "1.0.0",
"description": "create micro project for myself",
"main": "index.js",
"scripts": {
"start": "node ./build/run.js"
},
"author": "yancy",
"license": "ISC",
"devDependencies": {
},
"dependencies": {
}
}
ビルド\実行.js
const childProcess = require('child_process')
const path = require('path')
const filePath = {
vue2: path.join(__dirname, '../vue2'),
vue3: path.join(__dirname, '../vue3'),
react15: path.join(__dirname, '../react15'),
react16: path.join(__dirname, '../react16'),
main: path.join(__dirname, '../main')
}
// cd 子应用的目录 npm start 启动项目
function runChild () {
Object.values(filePath).forEach(item => {
childProcess.spawn(`cd ${
item} && npm start`, {
stdio: "inherit", shell: true })
})
}
runChild()