bs_base-8.x-1.x-dev/gulpfile.js
gulpfile.js
/**
* @file
* Provides Gulp configurations and tasks for bs_base theme and child themes.
*/
'use strict';
// Load gulp and needed lower level libs.
const gulp = require('gulp');
const yaml = require('js-yaml');
const fs = require('fs');
const sass = require('gulp-sass')(require('node-sass'));
const merge = require('deepmerge');
// Load gulp options first from this theme.
// @note - Be sure to define proper base themes relative paths first in
// gulp-options.yml. Most of the time default provided path is OK.
let options = yaml.load(fs.readFileSync('./gulp-options.yml', 'utf8'));
// Deep merge with gulp options from parent themes.
if (options.parentTheme) {
for (let theme of options.parentTheme) {
const parentThemeOptions = yaml.load(fs.readFileSync(theme.path + 'gulp-options.yml', 'utf8'));
// Due to change in deepmerge 2.x we need to remove parentTheme because it will not be properly merged.
delete parentThemeOptions.parentTheme;
options = merge(parentThemeOptions, options);
}
// Add parent path of parent themes, so we can do simple
//
// @import "bs_base/sass/init";
//
// in our sass files.
for (let theme of options.parentTheme) {
options.sass.includePaths.push(theme.path + '../');
}
}
// Lazy load gulp plugins.
// By default, gulp-load-plugins will only load "gulp-*" and "gulp.*" tasks,
// so we need to define additional patterns for other modules we are using.
const plugins = require('gulp-load-plugins')(options.gulpPlugins);
// Load gulp tasks from parent theme and this theme.
if (options.parentTheme) {
for (var theme of options.parentTheme.reverse()) {
require(theme.path + 'gulp-tasks.js')(gulp, sass, plugins, options);
}
}
require('./gulp-tasks.js')(gulp, sass, plugins, options);
