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
1 answer

Vue.js 2.0 Module build failed: SyntaxError: Unexpected token using webpack, Elixir and gulp

After spending almost complete day trying to upgrade from Vue.js 1.X to Vue.js 2.0 I'm still getting errors (using gulp watch) ERROR in …
Yuval Kaufman
  • 585
  • 1
  • 5
  • 17
4
votes
2 answers

SASS not compiling (watching) anymore when using serve after Ionic update

I have recently updated ionic and its libs, but that has changed many things for me. Right now, I can make some changes in the HTML and my livereload just shows them. When I do this in a certain SCSS file, nothing happens at all. So the ionic serve…
Siyah
  • 2,852
  • 5
  • 37
  • 63
4
votes
2 answers

How to run Gulp ESLint on HTML script tag JS

I have set up Gulp to ESLint the javascript in my HTML script tags with the following code. const eslint = require('gulp-eslint'); gulp.task('process-js', () => { const scripts = processInline(); return gulp.src(['src/*.html']) …
Svante
  • 1,069
  • 3
  • 12
  • 28
4
votes
1 answer

gulp: how to execute shell command and get the output

I need to run a shell command and write the results into a json file: const Shell = require('gulp-shell'); gulp.task('build-info', () => { gulp.src('./app/_bundle_info_.json') .pipe(jeditor((json) => { var buildNumber = Shell.task([ …
Xaree Lee
  • 3,188
  • 3
  • 34
  • 55
4
votes
1 answer

Chrome not reading source map generated by elixir browserify

I'm using Laravel elixir to compile my js and css files with gulp. I'm using Chrome to debug, and it's picking up the sourcemaps generated by mix.styles and mix.scripts but not the one generated by mix.browserify. I can't see what I'm doing wrong. I…
Erin
  • 527
  • 2
  • 4
  • 13
4
votes
1 answer

Gulp watch not emitting event object

Gulp (4.0) throws the error "Error: Invalid glob argument: undefined" when I attempt to gulp.src the path of a changed file obtained from gulp.watch. Both this: gulp.task('watch', function() { gulp.watch('./web/**/*.html') .on('change',…
dansalias
  • 737
  • 6
  • 11
4
votes
1 answer

Relative path to a file from an HTML template using gulp-file-include

What is the recommended way to link to CSS and JavaScript files from within an HTML template using…
Dem Pilafian
  • 5,625
  • 6
  • 39
  • 67
4
votes
0 answers

Resharper Updating Source Files on Gulp Watch

I am trying to configure Resharper for Visual Studio so it's not reanalyzing dist files when they are built. I am using gulp to watch js files and build to /dist when they change. When that happens, Visual Studios becomes unresponsive and "Updating…
micah
  • 7,596
  • 10
  • 49
  • 90
4
votes
0 answers

SystemJS Builder: minify html and css during build

I'm learning how to use SystemJS Builder 0.15.30 to bundle my Angular 2 rc.6 application written in typescript 2. I use gulp 3.9.1 for building: Each component in my application has 5 files: component.ts component.html component.scss component.css…
BeetleJuice
  • 39,516
  • 19
  • 105
  • 165
4
votes
1 answer

Why gulp-gzip and can I serve gzipped content without configuring the server?

I ran into a dilemma lately as I was exploring the various plugins for gulp. One of them was gulp-gzip and till then, I have never thought about compressing my files. I got gulp-gzip to work correctly and spit out gzipped versions of my HTML, CSS…
sangeeth96
  • 1,202
  • 1
  • 11
  • 20
4
votes
1 answer

gulp typescript: error TS1005

I am creating angular2 typescript application. I am using angular/material2 in order to present better design. As for building the project - I am using gulp. Problem statement: I changed @angular/router-deprecated to @angular/router and was forced…
Eduard
  • 346
  • 4
  • 15
4
votes
1 answer

Why does vinyl.isVinyl() return false for vinyl files emitted by gulp?

I am learning about the gulp source code and tried to write a gulp plugin. Now I am confused about something. This is my plugin code below: module.exports = function(){ return through2.obj(function(file,encode,callback){ …
kwoktung
  • 572
  • 1
  • 4
  • 12
4
votes
1 answer

What does '...paths.js' mean in ' gulp.src([...paths.js, '!gulpfile.babel.js'], { base: '.' }) '?

I have the following gulp task: // Compile ES6 to ES5 and copy to dist gulp.task('babel', () => gulp.src([...paths.js, '!gulpfile.babel.js'], { base: '.' }) .pipe(plugins.newer('dist')) .pipe(plugins.sourcemaps.init()) …
Colin Wang
  • 6,778
  • 5
  • 26
  • 42
4
votes
2 answers

require("lodash") - require is not defined

I saw this lodash-thing once and thought it would be nice to use. So I try now for days, but can't get it running. Please be patient as I'm a noob in this thing. I have npm install lodash --save .. so it is in my node_modules and in my package.json…
99Problems
  • 155
  • 1
  • 2
  • 8
4
votes
2 answers

Angularjs - How to debug and log when developing an Office add in

I am developing and Office add in using AngularJS and the adal-angular template provided by Microsoft through the Yeoman Office generator. After everything was configured correctly I published my manifest.xml to a file share. I then told Excel to…
Detilium
  • 2,868
  • 9
  • 30
  • 65
1 2 3
99
100