Eccenca common gulp tasks (ecc-gulp-tasks)
A set of common gulp tasks for front-end development
Before you follow the instructions below, make sure that
ecc-gulp-tasks is up to date.
You may do that by running
gulp doctor --self-check.
If you are sure, you want to update your environment, you can follow these steps:
Find out which node packages are installed globallynpm ls -g --depth 0yarn global ls
Update env# update nvmrc and nodebash -c "echo "6.9.4" > ~/.nvmrc"nvm install# install latest npm and yarnnpm install --global email@example.com firstname.lastname@example.org
Reinstall you installed with npm/yarn, for example:yarn global add gulp eslint ecc-license-checker
bad-mdl- finds several bad mdl classes. We want to use the ecc-gui-elements instead of using those bad classes directly.
build- compiles optimized (minified, deduped) commonjs version of your component with webpack. Uses
config.webpackConfig.productionas basic configuration.
build-app- compiles optimized (minified, deduped) application with webpack. Uses
config.webpackConfig.applicationas basic configuration.
debug- compiles debug version of your component with webpack, watches for changes and re-compiles when needed (until interrupted). Uses
config.webpackConfig.debugas basic configuration.
test- runs mocha tests starting from file specified at
cover- runs istanbul to generate test coverage from file specified at
lint- runs eslint on files specified at
licenses-yaml2json- generates a
doctor- runs several checks in the project. Some of them are fixable by running
gulp doctor --heal
- Include into your project using
npm i --save-dev ecc-gulp-tasks
gulpfile.jslooks like this:
var gulp = ;gulp;
As you can see, you need to provide two arguments while requiring the package. First one is an array of string names of available tasks you wish to use. The second one is your build config (described below).
Adding custom gulp tassk
If you need to use your custom gulp tasks after including common ones, you can do it like so:
var gulp = /* ... */;// define task inlinegulp;// load your custom tasks from external filegulp;// ...
How to run things synchonously?
Normally gulp runs everything asynchronously, but sometimes you might want to run tasks in sync. That is useful for example if you want to run tests and then build a component. To do that, you can use gulp-sequence package, like so:
var gulpSequence = ;var gulp = /* ... */;// ....gulp;
Example build config looks like this:
var path = ;moduleexports =testEntryPoint: pathwebpackConfig:debug:production:application:common:context: pathlicenseReport:input: pathoutputName: 'licenses.json'outputPath: path;
Exported parameters are as follows:
testEntryPoint- should point to your test entry point (to be run by mocha)
webpackConfig.debug- should include your webpack config used for debugging
webpackConfig.production- should include your webpack config used for compilation for production
webpackConfig.application- should include your webpack config used for compilation as production application. It allows for the following special parameters:
webpackConfig.common- may webpack config that
webpackConfig.applicationhave in common
licenseReport- should point to a license yaml file and contain parameters for the generated license report
There are the following flags set:
__WEBPACK__ is set to true while using
This may be used for doing things only webpack can do, like requiring style sheets, etc:
__DEBUG__ is set to
If you run
__DEBUG__ is set to
false, effectively stripping all debug statements.
This may be used for doing things only during development:
// The following block will only be run during developmentif__DEBUG__console
__VERSION__ is set to
If the environment variable
GT_BUILD_VERSION is set,
__VERSION__ will be set to that value.
Otherwise it will be set to the result of
git describe --always --dirty, if that does not fail.
const version = <div>__VERSION__</div>;