Common gulptasks with interface for overriding tasks and configs in starter packs.
First install the gulp starter by adding
netliferesearch/starter-gulp to your
package.json file, or by simply issuing the following command in the terminal when standing in your projects root folder
npm i starter-gulp --save-dev
If npm ends by telling you something like the line shown below, you need to add
gulp as a dev dependency in your project.
npm WARN email@example.com requires a peer of gulp@^3.9.0 but none was installed.
Now, all that is left in order for the gulp tasks to work in your project is connecting gulp with the starter gulp tasks. Create a
gulpfile.js in your root dir that looks something like this:
'use strict';var gulp = ;var starterGulp = ;starterGulp;starterGulp;
Now, you should be able to run
gulp in your project.
If you want to override the default gulp config, you pass an object to the
extendConfig function in the example below. This config is merged into the default config and will override the override properties with the same name in the default config.
In most projects you'll probably need to tweak the gulp tasks a bit, and this is done by passing an object containing the tasks that you want to override. An example of a task that logs foo to the console and requires the task
bar to be run before it runs can be passed to the
extendTasks function like this:
If you're adding multiple tasks, you will of course want to split it into separate files:
The configuration file is exposed, and is accessable through the
config property on the
starter-gulp object, like this:
var config = config;
If you want to get hold of the browserSync instance in order to trigger reloading or doing other (fun) stuff, you can access it as the
browserSync property on the
starter-gulp object, and use it in your task like this:
var browserSync = browserSync;gulp;