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
2 answers

How to disable comments on "twig"?

I use gulp-twig and handlebars.js in the project I work in the file index.twig In twig the symbol # means a comment. For the handlebars template, I need to use the {{#each}} line But twig perceives it as a comment, how to be? I'm sorry for bad…
enot
  • 141
  • 1
  • 8
4
votes
1 answer

local gulp not found after installing globally and locally

I have installed gulp both globally sudo npm install --global gulp-cli and locally npm install --save-dev gulp /usr/local/bin/gulp exists, and ./node_modules/gulp and ./node_modules/gulp-cli exist. When I try to run gulp on the command line, I get…
Troy Daniels
  • 3,270
  • 2
  • 25
  • 57
4
votes
0 answers

Add React Component to Laravel

I'm new to Laravel and react and I just wanted to use react component along side with Laravel. I followed the process described here but when I run gulp watch I get this error:…
Kibo
  • 870
  • 1
  • 15
  • 30
4
votes
2 answers

How can I run a gulp imagemin task only on new and changed files?

I tried to add a gulp task like below and run gulp images so that it only runs only on added/changed files However, that seems to not work...Any idea? gulp.task('images', function (event) { switch (event.type) { case 'added': case…
Hello Universe
  • 3,248
  • 7
  • 50
  • 86
4
votes
2 answers

vueify (in gulp task) with babel transform of vue files

fixed. The solution is to: pass through .transform(babelify) as well ensure all your .vue-file script elements look like