Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

I am using angular-cli@webpack.

I have configured my node services using gulp and to run my json-server I am executing my 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 .

I want to have a functionality that after angular-cli completes bundling of my app , json-server should be started.

I have tried including below command in 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. If I include gulp before ng serve then only gulpfile runs, webpack doesnt run the angular2 application.

So is there any way I can run both tasks simultaneously?

any inputs?

thanks in advance.

like image 246
Bhushan Gadekar Avatar asked Sep 12 '16 06:09

Bhushan Gadekar


People also ask

Can I use Gulp with Webpack?

Fortunately for us, Webpack has a Node API to allow us to invoke it from a Node environment, so incorporating this in to a Gulp task will be super easy. First, require the webpack module in gulpfile. js (if you're adding this to an existing Webpack project, you will already have Webpack installed.)

Is Gulp an alternative to Webpack?

Gulp can manage only a single application, and it is never a replacement for Webpack, whereas Webpack can be used as a replacement for Gulp. As both uses JavaScript, users will not feel different while migrating from Gulp to Webpack.

Is Gulp still relevant?

It's no longer necessary with tools like create-react-app and next-js. Gulp used to make sense before Webpack and React. You needed to process files, build your project, and have a functioning web server (BrowserSync) that refreshes the browser when you make changes.

How does Gulp work?

Gulp purely uses the JavaScript code and helps to run front-end tasks and large-scale web applications. It builds system automated tasks like CSS and HTML minification, concatenating library files, and compiling the SASS files.


1 Answers

Finally I found one solution for this on windows.

it states that using below command in package.json can run both gulp & webpack simultaneously:

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

Thanks for the response.

like image 78
Bhushan Gadekar Avatar answered Sep 28 '22 04:09

Bhushan Gadekar