Gulp Worker
This package is a gulp utility to help creating a single combined css or javascript file from several files. The combined files also can be appended by version. The version can read from changelog.txt file or manually inputted when running the gulp.
Installation
Use the console and run this:
npm install gulp-worker
Importing
Create a gulpfile.js and put this as content:
var worker = ;
Usage
Gulp worker can be run using command:
gulp
This command will only run the default task once. In case you want to run the gulp watching changes happens to registered files, run this command:
gulp watch
If you want to put the version in the result file, use --build version
gulp --build 016
If you want to enforce development built, regardless of combined or minified settings to produce combined only
gulp --development
If you want to enforce production built, regardless of combined or minified settings to produce minified only
gulp --production
The same additional parameters also can be used for gulp watch
Available Configuration
There are some configurations available for gulp worker together with their default values:
config =//folder and naming configurationname: "default" // name of output filecombinedPrefix: "" // prefix for combined filecombinedPostfix: "" // postfix for combined fileminifiedPrefix: "" // prefix for minified fileminifiedPostfix: ".min" // postfix for minified filedestination: "./" // output folderbaseFolder: "./" // base source folder//Versioning ConfigurationversionOnDestinationFolder: false // put version number in folderversionOnFile: false // put version number in fileautomaticVersioning: true // put version name based on changelog file versionchangelogFileName: "changelog.txt" // changelog file namegulpOnWatch: true // When watch, trigger default task//Combining ConfigurationcombinedDestination: null // destination for combinedcreateCombined: true // create combined fileminifiedDestination: null // destination for minifiedcreateMinified: true // create minified filegenerateSourceMaps: true // generate source map//debugdebug: falsedebugLevel: "debug"inclusionTags: // to either exclude or include when certain tag is defined when executing gulp, for example: inclusionTags = ["i-include"]; gulp --i-includeexclusionTags:;
Global Configuration Overriding
In order to override global configuration, there is a function configure. Here is an example:
worker
This will only override configuration specified. If you want to override specific configuration without using configure and have the same result:
workerconfigdestination = "./build";workerconfigbase_folder = "./src";
Usage Code
The code for gulpfile.js will have the format of worker.PROCESS_NAME(SOURCE_ARRAY,ADDITIONAL_CONFIGURATION). Current available processes are css, less, and js. Additional configuration will only override defined config for specific work. Here is the example:
worker;
Chaining
In case you want to use same sets of files, but different configuration, you can use .chain after the .js, .css, or .less command to generate a task using same files but different configurations.
The structure of chain is .chain(options). Here is the example:
worker;