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.
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.)
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.
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.
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With