在webpack构建脚本中,'awesome-typescript-loader'作为单独的进程启动。当webpack退出时,这个单独的进程还没有完成,所以我无法运行PM2重新加载过程......
有没有办法检测这个单独进程的结束,以便按时正确启动PM2重新加载?
要检查webpack时间线,我添加了一个特定的插件
new WebpackShellPlugin({onBuildStart:['echo "Webpack Start"'],
onBuildEnd:['echo "Webpack End"'], onBuildExit:['echo "Webpack Exit"']})
跑步:
node_modules/.bin/webpack --config webpack.config.prod.js --progress --profile --bail
控制台日志:
@example.com Executing pre-build scripts
@example.com "**Webpack Start**". # echo from WebpackShellPlugin
@example.com
@example.com [at-loader] Using typescript@2.0.10 from typescript and "tsconfig.json" from /opt/hello-angular/releases/20161206103220/tsconfig.json
@example.com
@example.com [at-loader] Checking started in a separate process...
# is there a way to keep track this process ?
@example.com
@example.com [at-loader] Ok, 5.531 sec.
@example.com Executing post-build scripts
@example.com "**Webpack End**" # echo from WebpackShellPlugin
@example.com Executing additional scripts before exit
@example.com "**Webpack Exit**". # echo from WebpackShellPlugin
@example.com Hash: 5c4be87232dc5ea6d7fa
@example.com Version: webpack 2.1.0-beta.27
@example.com Time: 70161ms
@example.com Asset Size Chunks Chunk Names
@example.com bundle.js 376 kB 0 [emitted] app
@example.com + 441 hidden modules
...
.... # [at-loader] output long process ....
5693ms asset optimization
....
@358ms emitting
localhost$. # [at-loader] process finished )
is there a way to get warned when the separate process ends up, and run my pm2 start command at this point ?
答案 0 :(得分:1)
我找到了一个解决方案,在我的shipit任务中使用回调函数......
// this task builds the Angular bundle in the release folder
shipit.blTask('build_script', function () {
shipit.remote('cd '+ shipit.releasePath + ' && npm run build:' + env).then(function (res) {
console.log("WEBPACK BUILD CALLBACK FUNCTION... NOW RESTART PM2");
shipit.start('pm2-startOrReload');
});
});