@gravityforms/gulp-tasks
Version:
Configurable Gulp tasks for use in Gravity Forms projects.
68 lines (60 loc) • 2.91 kB
JavaScript
const gulp = require( 'gulp' );
const { resolve } = require( 'path' );
const header = require( 'gulp-header' );
const getConfig = require('../../config');
const { config } = getConfig();
const iconConfig = require( '../utils/icon-config' );
const { trailingSlashIt } = require( '../utils/tools' );
const designTokensPath = resolve( __dirname, '../../../design-tokens' );
const {
childDir = '',
designTokenDir = '',
parentDir = '',
target = 'admin',
targetCssDir = '',
} = iconConfig;
module.exports = Object.assign( {}, {
iconsStyle() {
const parentDirPath = parentDir ? `${ parentDir }/` : '';
const targetCssDirPath = targetCssDir ? targetCssDir : target;
const childDirPath = childDir ? `/${ childDir }` : '';
return gulp.src( `${ config.paths.css_src }/${ parentDirPath }${ targetCssDirPath }${ childDirPath }/icons/_icons.pcss` )
.pipe( header( `/* stylelint-disable */
/* -----------------------------------------------------------------------------
*
* ${ target.charAt( 0 ).toUpperCase() + target.slice( 1 ) } Font Icons (via IcoMoon)
*
* This file is generated using the \`gulp icons\` task. Do not edit it directly.
*
* ----------------------------------------------------------------------------- */
` ) )
.pipe( gulp.dest( `${ config.paths.css_src }/${ parentDirPath }${ targetCssDirPath }${ childDirPath }/icons/` ) );
},
iconsVariables() {
const parentDirPath = parentDir ? `${ parentDir }/` : '';
const targetCssDirPath = targetCssDir ? targetCssDir : target;
const childDirPath = childDir ? `/${ childDir }` : '';
if ( designTokensPath && designTokenDir ) {
return gulp.src( `${ trailingSlashIt( designTokensPath ) }${ trailingSlashIt( designTokenDir ) }custom-properties/${ parentDirPath }${ target }${ childDirPath }/icons.js` )
.pipe( header( `/**
* ${ target.charAt( 0 ).toUpperCase() + target.slice( 1 ) } Icons (via IcoMoon)
*
* This file is generated using the \`npm run icons\` task. Do not edit it directly.
*/
module.exports = {` ) )
.pipe( gulp.dest( `${ trailingSlashIt( designTokensPath ) }${ trailingSlashIt( designTokenDir ) }custom-properties/${ parentDirPath }${ target }${ childDirPath }/` ) );
} else {
return gulp.src( `${ config.paths.css_src }/${ parentDirPath }${ targetCssDirPath }${ childDirPath }/variables/_icons.pcss` )
.pipe( header( `/* stylelint-disable */
/* -----------------------------------------------------------------------------
*
* Variables: ${ target.charAt( 0 ).toUpperCase() + target.slice( 1 ) } Icons (via IcoMoon)
*
* This file is generated using the \`npm run icons\` task. Do not edit it directly.
*
* ----------------------------------------------------------------------------- */
:root {` ) )
.pipe( gulp.dest( `${ config.paths.css_src }/${ parentDirPath }${ targetCssDirPath }${ childDirPath }/variables/` ) );
}
},
}, config?.tasks?.builtins?.header || {} );