gulp-core-build is a set of utility functions that makes it easy to create gulp-based build rigs. Instead of having unweildy unmaintainable gulpfiles in every project, we want the build setup to be as reusable and centralized as possible.
The gulp build system, along with its rich plugin ecosystem, is a very powerful tool for web development projects. However project gulp build setups become difficult to manage over time, as gulpfiles grow in complexity. This project simplifies a number of aspects of getting a build setup going for a majority of scenarios.
Core build defines a contract for tasks to implement, such that they can share opinions about where things end up. Tasks are modular but they are designed to work well together.
With gulp core build, your gulpfile translates into a list of task definitions, each which define what to run:
'use strict';// Import core build and the tasks the project needs.;;;;;;;// Define gulp tasks.;;;;;// Initialize!build.initializerequire'gulp';
Within your project, install gulp, gulp-core-build, and the tasks you need:
npm install --save-dev gulp gulp-core-build
Then install the tasks you need:
npm install --save-dev gulp-core-build-typescript gulp-core-build-karma gulp-core-build-webpack gulp-core-build-serve
Create a gulpfile.js that sets up the tasks in the way you want them to run:
'use strict';// Import core build.let build = ;// Import the tasks.let lint = tslint;let typescript = typescript;let sass = default;let karma = default;let webpack = default;let serve = default;// Shorthand for defining custom subtasks// The proper method for this is to introduce a new package which exports a class that extends GulpTask// However, this shorthand allows an easy way to introduce one-off subtasks directly in the gulpfilelet helloWorldSubtask = build;// Define gulp tasks.let buildTasks = build;let testTasks = build;let bundleTasks = build;let serveTasks = build;let helloWorldTasks = build;let defaultTasks = build;// Tell the build to set up gulp tasks with the given gulp instance.build;
Once this is set up, you should be able to execute the gulp tasks and they should run in the order you defined.
|gulp-core-build-typescript||Builds and lints typescript.|
|gulp-core-build-sass||Compiles sass into css, into js modules, that are theme friendly.|
|gulp-core-build-webpack||Runs webpack given a config, and outputs libraries plus the stats and logging.|
|gulp-core-build-serve||Sets up a server and live reload for a quick dev loop.|
|gulp-core-build-karma||Runs unit tests in a browser using Karma|
|gulp-core-build-mocha||Runs unit tests in a NodeJS environment with Mocha|
Defines a named task to be registered with gulp as a primary gulp task, which will run the provided task when execution.
Runs a given list of tasks in parallel execution order.
Runs a given list of tasks in serial execution order.
Creates a subtask (which is not registered directly with gulp, use
task() for that) which can be
this variable in the callback function will be an instance of a
fn should be a function of type
/*** The callback interface for a custom task definition.* The task should either return a Promise, a stream, or call the* callback function (passing in an object value if there was an error).*/
Registers the gulp tasks.
The options are broken down into task-specific sections, and all are optional, so only provide the ones that require deviating from defaults:
Suppresses a warning or an error message. It will no longer be displayed in the build logs, nor will the warning or error cause the build to fail.
// Suppresses this exact warningbuild.addSuppression"Warning - tslint /foo/bar/test.tsx no-any"// Suppresses anything with "tslint"build.addSuppression/tslint/
npm install --force
subtask() function is used to define a custom task. For example,
you could create the following subtask, which is registered to the command
let helloWorldSubtask = build;// Register the task with gulp command linelet helloWorldTask = build;
Note that the command
gulp do-hello-world-subtask would error.