简体   繁体   English

如何在angular-cli @ webpack完成捆绑后运行gulp任务?

[英]how to run a gulp task after angular-cli@webpack finishes bundling?

I am using angular-cli@webpack. 我正在使用angular-cli @ webpack。

I have configured my node services using gulp and to run my json-server I am executing my gulpfile: 我已经使用gulp配置了我的节点服务并运行我的json-server我正在执行我的gulpfile:

var gulp = require('gulp');
var gulpif = require('gulp-if');
var server = require('gulp-express');
var args = require('yargs').argv;
var typescript=require('gulp-typescript');
var sourcemaps = require('gulp-sourcemaps');
var del = require('del');
var tsconfig = typescript.createProject('src/tsconfig.json');

gulp.task('default',function(){
    // Start the server at the beginning of the task 
    console.log('Start the server at the beginning of the task');
    server.run(['server/json-server-starter.js']);
});

Now for running my angular2 project I am using npm start . 现在运行我的angular2项目我正在使用npm start

I want to have a functionality that after angular-cli completes bundling of my app , json-server should be started. 我希望有一个功能,在angular-cli完成我的应用程序的捆绑之后,应该启动json-server。

I have tried including below command in package.json : 我试过在package.json中包含以下命令:

"scripts": {
    "start": "ng serve && gulp",
    "lint": "tslint \"src/**/*.ts\"",
    "test": "ng test",
    "pree2e": "webdriver-manager update",
    "e2e": "protractor"
}

But it doesnt run the gulpfile after bundling the app. 但是在捆绑应用程序后它没有运行gulpfile。 If I include gulp before ng serve then only gulpfile runs, webpack doesnt run the angular2 application. 如果包括我gulp之前ng serve则只有gulpfile运行,的WebPack犯规运行angular2应用。

So is there any way I can run both tasks simultaneously? 那么有什么办法可以同时运行这两个任务吗?

any inputs? 任何输入?

thanks in advance. 提前致谢。

Finally I found one solution for this on windows. 最后我在Windows上找到了一个解决方案。

it states that using below command in package.json can run both gulp & webpack simultaneously: 它声明在package.json中使用下面的命令可以同时运行gulp和webpack:

"start": "start ng serve && start gulp"

Thanks for the response. 谢谢你的回复。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM