Questions tagged [gulp]

Gulp is a JavaScript build system, Node.js-based task runner like Grunt. Gulp uses streams and code-over-configuration for a simpler and more intuitive build process.

Gulp is a build system, -based task runner like . It can automate common tasks during your development process. Gulp uses the streams-concept and code-over-configuration for a simpler and more intuitive build process. The code-over-configuration concept can create more readable and simple tasks, despite tasks which are highly over-configured.

Install

First you have to install gulp globally:

npm install gulp -g

After that you should add gulp to your project (package.json file):

npm install --save-dev gulp

Then you should create a file named gulpfile.js and define your tasks in that. Any valid node.js code can be used in gulpfile.js (like defining functions, importing extra modules, etc.).

After you created your tasks, you should export them (as you would in any other module). And then you can run the task by running gulp <task name> in terminal (in the project folder). Running gulp without specifying would run the default task if present (the main task is usually named default to be more convenient)

Example

const gulp = require('gulp');
const less = require('gulp-less');
const autoprefix = require('gulp-autoprefixer');

gulp.task('css', () => {
   gulp.src('assets/app.less')
      .pipe(less())
      .pipe(autoprefix('last 2 version', 'ie 8', 'ie 9'))
      .pipe(gulp.dest('build'));
});

And to run this task, run this in terminal:

$ gulp css

Useful Links

Related Tags

12677 questions
4
votes
0 answers

Is there a way to use a variable in package.json?

Is there a way to use a variable in package.json? so if I want to swap all angular versions I can just do it one spot, instead of 11... }, "dependencies": { "@angular/common": "2.3", "@angular/compiler": "2.3", "@angular/core":…
born2net
  • 24,129
  • 22
  • 65
  • 104
4
votes
1 answer

Error EOF when trying to resize images using Gulp on Windows

I get an error as follows when calling resize:images task in my gulpfile (see bottom) ... events.js:160 throw er; // Unhandled 'error' event ^ Error: Error: write EOF at finish…
Brendan
  • 18,771
  • 17
  • 83
  • 114
4
votes
1 answer

How to run gulp task and spring-boot:run together with maven?

I have two project, framework that is Spring boot application, and another is framework-web that contains html layouts and web ui. I run maven with this goals, clean install to install framework into local repository. Then i want to run maven with…
Rasool Ghafari
  • 4,128
  • 7
  • 44
  • 71
4
votes
1 answer

Can Azure compile TypeScript and execute Gulp tasks?

I'm developing .NET Core app with TypeScript + Angular 2. And I want to deploy that on Azure. When I do this, I see the following build error after Azure get code from my repository: "VSTSC : error TS5023: Build: Unknown compiler option 'lib'.…
A. Gladkiy
  • 3,134
  • 5
  • 38
  • 82
4
votes
1 answer

Gulp SASS Sourcemap sources are incorrect

I am struggling to get my SASS sourcemaps to work correctly. The problem seems to be the "sources" attribute within the sourcemap and how my SASS files are nested. I have a Gulp task that compiles SASS to CSS. Here is an example of that var paths =…
4
votes
1 answer

Angular module not available with Gulp Babel

I am getting the following error in my Angular app after adding gulp babel to my gulp file. I need this to transpile and minify my ES6: Cannot set property '0' of undefined I'm thinking angular-file-saver doesn't like to babelfication. Causing…
user3871
  • 12,432
  • 33
  • 128
  • 268
4
votes
1 answer

Error when running npm install gulp on kudu

I am running a setup which automatically deploys my app from Github using the Github deployment option in Azure Web Apps. However, i have just created a new Azure web app and deployed my application to it using the usual method, however this time…
Jorje Redemption
  • 809
  • 1
  • 7
  • 17
4
votes
1 answer

How do I bundle a reuseable angular 2 component for multiple apps?

I want to create a reusable component that I can bundle into a single js file and share with different angular 2 apps. However, I keep getting Error: (SystemJS) Unexpected value 'undefined' declared by the module 'AppModule' I use gulp to build my…
i8abug
  • 1,692
  • 3
  • 19
  • 31
4
votes
1 answer

Aurelia CLI and gulp notifications (Windows)

How do I disable the gulp toast notifications (Windows 10) when rebuilding my app using the aurelia-cli. Extremely annoying.
Eric Gurney
  • 263
  • 2
  • 11
4
votes
1 answer

Gulp Jscs - TypeError: Cannot convert undefined or null to object

I wanted to use gulp-jscs in my project, so I've installed it according the documentation: npm install --save-dev gulp-jscs But when I try to run the gulp file, I'm getting this error: TypeError: Cannot convert undefined or null to object at…
ToTa
  • 3,304
  • 2
  • 19
  • 39
4
votes
0 answers

Gulp not concatenating js file in correct order

I am concatenating and minifying js files using gulp. But files are not concatenating in the order it should be, like this is the order I want : var scriptFiles = [ 'assets/lib/js/angular.min.js', 'assets/lib/js/angular-sanitize.min.js', …
Rahul Sagore
  • 1,588
  • 2
  • 26
  • 47
4
votes
1 answer

Gulp Rename illegal operation

My gulp file looks like: function aureliaJsonPath(name) { return `./aurelia_project/aurelia.${name}.json`; } gulp.task('use-login-au-json', () => { return gulp.src(aureliaJsonPath('login')) .pipe(rename('aurelia.json')) …
Callum Linington
  • 14,213
  • 12
  • 75
  • 154
4
votes
3 answers

Unable to install gulp-jshint through npm

while installing gulp-jshint using node npm following error is showing "gulp-jshint@2.0.4 requires a peer of jshint@2.x but none was installed-UNMET peer dependency". Can anyone help to solve this problem. I am using windows 7 OS.
Aravindh A
  • 41
  • 1
  • 3
4
votes
1 answer

Intellij constantly compiles TypeScript (very slow) - How to stop this behavior?

I am in the process of migrating an Angular 1.x project from vanilla JS to TypeScript. However, I am experiencing extremely slow response times from my IDE. If I uncheck "Track changes" in Settings > Languages & Frameworks > TypeScript, the…
Cities
  • 163
  • 1
  • 11
4
votes
1 answer

How to pipe input to uglify-js-harmony in gulp

I want to uglify some JS containing classes. This is not supported by gulp-uglify at the moment as discussed here. I have done . . npm install uglify-js-harmony --save-dev as advised in the previous answer, but being new to front end dev in…
learnvst
  • 15,455
  • 16
  • 74
  • 121
1 2 3
99
100