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

12395 questions
4
votes
4 answers

Visual Studio Code complains that it "Cannot find namespace" for types defined in *.d.ts files

I created a new project using the gulp-angular Yeoman generator with language set to TypeScript. Then ran the Gulp build process and also opened the page in a web browser, which all worked without any bigger problems. I only had to replace ref:…
zabbarob
  • 1,080
  • 2
  • 11
  • 23
4
votes
1 answer

Structure of Laravel App (API, Back office, Front office)

I need help for the structure of my Laravel App. What I want is basically this structure : API Admin panel Public website I started to build this folder structure which I think is pretty correct : app/ Http/Controllers/ API/ …
David
  • 4,490
  • 6
  • 31
  • 54
4
votes
0 answers

Gulp watch task runs once, then hangs on the 2nd run

I have some gulp tasks to run my TSLint checks for a project. I have a task to only watch the newly changed files and run the checks for these when they change (upon file save). Currently when I run the watchTS task, it will run and work fine upon…
CBarr
  • 21,475
  • 18
  • 85
  • 119
4
votes
2 answers

How run multiple servers with Gulp?

I am trying to run Gulp for open 2 servers both with livereload at the same time. Is it possible? My code: http://pastebin.com/B6GAuvWB
4
votes
3 answers

gulp.src() include files but ignore all folders

There is certainly such a simple answer to this that I can't find anyone that's asked it before: What globbing pattern to include all the files in a folder but ignore ALL subfolders? gulp.src('*') includes all files and folders. I just want the…
sthames42
  • 752
  • 7
  • 15
4
votes
2 answers

Parse main bower files (js, css, scss, images) to distribution via Gulp

We have recently switched from using a PHP asset manager to Gulp. We use bower to pull in our frontend packages and their dependencies. Using simple Bower packages that only have JS files listed in 'main' is pretty straightforward and is easily…
4
votes
2 answers

Pass data between gulp tasks without writing to disk

I'm trying to annotate and minify a systemjs angular project. Systemjs comes with a build function, but it is not `'gulp-aware'. There is the possibility to pass the builder an option to minify, but there is not one for ng-annotate, so I will need…
Simon H
  • 17,952
  • 10
  • 57
  • 101
4
votes
0 answers

Minifined moment.js file with specific locale using Gulp and require.js?

When you get moment.js library from Bower, there are these minified packages: moment.min.js - without locales moment-with-locales.min.js - with all locales included (still quite big file) My goal is to create ONE minified moment.js file that would…
ECM4D
  • 156
  • 9
4
votes
1 answer

How can I run gulp-nodemod in debug mode?

I have tried: var nodemon = require('gulp-nodemon'), nodemon({ script: 'src/server.js', debug: true }); However, the debug flag isn't getting passed along to node
linuxdan
  • 3,399
  • 3
  • 22
  • 36
4
votes
1 answer

require('jquery') not defined using elixir / Gulp

I'm using elixir and I can't get to work any JS using JQuery I keep getting this : var jQuery = require('jquery'); //Uncaught ReferenceError: require is not defined Here is my elixir function: elixir(function(mix) { mix.sass('app.scss'); …
commandantp
  • 907
  • 1
  • 12
  • 25
4
votes
2 answers

How to use yargs array syntax with gulp?

Using array syntax of yargs with gulp throws errors. Here is my code: var argv = require("yargs") .array("modules") .argv; and using it like this: gulp taskname --modules m1 m2 Task 'm2' is not in your gulpfile How can I set an array using…
alisabzevari
  • 7,178
  • 6
  • 38
  • 60
4
votes
1 answer

how wrench plugin is useful for in gulp

I was learning gulp. I had come thru following code. wrench.readdirSyncRecursive('./gulp').filter(function(file) { return (/\.(js|coffee)$/i).test(file); }).map(function(file) { require('./gulp/' + file); }); Can somebody help me to understand…
dip
  • 1,221
  • 1
  • 17
  • 32
4
votes
3 answers

gulp connect not opening browser

I tried setting up the least possible setup for gulp-connect. It shows the following in the terminal window: Server started http://localhost:8080. However it doesn't start Chrome as expected and seen in this video. var gulp = require('gulp'), …
Kris van der Mast
  • 15,905
  • 7
  • 35
  • 57
4
votes
0 answers

Browsersync within Vagrant VM does not properly proxy

I'm having an issue where browser-sync is not properly proxying my apache2 server. I'm running browser-sync through gulp within an Ubuntu 14.04 VM with Ubuntu 15.04 on the host. I'm using the following configuration: browserSync({ proxy:…
4
votes
1 answer

Gulp and Browser-sync 404 on all external js and css files

So I am new to gulp and have been following the docs. So far everything has been working fine until I got to browser-sync. If I run gulp everything transpiles and is moved where it needs to go. The browser loads the index.html file on port 3000.…
Vikk
  • 537
  • 6
  • 16
1 2 3
99
100