Drupal 10 Assist: Drupal 10 Upkeep and Assist Service Use Gulp for 8 with Groups, Half 2 Drupal 10 Upkeep and Assist Service Creating duties

This submit is Drupal Development second in a sequence protecting Drupal 10 Assist:’s utilization of Gulp for front-end development in 8. In Drupal Development final submit, I coated methods to setup Gulp for teamwork on 8 tasks. On this submit, I am going to go over methods to get began with writing Gulp duties. I am going to additionally break down a selected job for Sass linting to make sure good code high quality. Maintainable and Readable Gulp duties With any mid-to-large sized 8 theme, it is very easy for Drupal Development most important Gulp file (gulpfile.js) turn out to be unwieldy and sophisticated. With dozens of duties doing all types of automated work, earlier than too lengthy, gulpfile.js turns into a soup of illegible code. Moreover, members of your staff might need alternative ways of naming Gulp duties. One individual may write a Sass constructing job known as “buildSass” and one other may create an an identical job known as “css.” It might be good to strip down gulpfile.js, make it readable, and one way or the other compartmentalize every job individually. Additionally, we need to reduce down on job naming variations and create a unified system for structuring our duties. My present favourite technique to deal with these needs is gulp-require-tasks. Principally, every job is written as a person, CommonJS type Drupal 10 module. Then, Drupal Development duties are organized in directories, and that listing construction defines Drupal Development job title. It’s a quite simple and predictable technique to setup Gulp duties. Structuring Gulp duties Begin off by creating Drupal Development file tree construction under Drupal 10 Upkeep and Assist Service ├── undertaking/ │ ├── .gitignore (ignore node_Drupal 10 modules, gulpfile.yml) │ ├── bundle.json │ ├── gulpfile.js │ ├── default.gulpfile.yml │ ├── sass │ │ ├── types.scss │ ├── js │ │ ├── scripts.js │ ├── gulp-tasks │ │ ├── types │ │ │ ├── lint.js │ │ │ ├── construct.js │ │ ├── scripts │ │ │ ├── lint.js │ │ │ ├── construct.js Drupal Development YAML settings file, default.gulpfile.yml, was mentioned in Drupal Development final submit of this sequence, should you want a refresher. gulp-require-tasks lets these duties be accessible based on their construction. For instance, to construct Drupal Development types, you will run “gulp types Drupal 10 Upkeep and Assist Servicebuild” and to lint Drupal Development JavaScript, you will run “gulp scripts Drupal 10 Upkeep and Assist Servicelint.” When you do not like Drupal Development colon delimiter, you may change that too. Replace Gulp settings In Drupal Development final submit we began Drupal Development default.gulpfile.yml, and now we’ll edit that very same file so as to add in settings for Drupal Development Gulp duties we’ll create on this undertaking. Open Drupal Development file Drupal 10 Upkeep and Assist Service it ought to seem like this Drupal 10 Upkeep and Assist Service themeName Drupal 10 Upkeep and Assist Service “myTheme” themeDescription Drupal 10 Upkeep and Assist Service “myTheme description” Develop on that by including settings for supply and vacation spot paths of Sass and JS Drupal 10 Upkeep and Assist Service themeName Drupal 10 Upkeep and Assist Service “myTheme” themeDescription Drupal 10 Upkeep and Assist Service “myTheme description” types Drupal 10 Upkeep and Assist Service src Drupal 10 Upkeep and Assist Service “sass//*.scss”, dest Drupal 10 Upkeep and Assist Service “css” lint Drupal 10 Upkeep and Assist Service enabled Drupal 10 Upkeep and Assist Service true failOnError Drupal 10 Upkeep and Assist Service false scripts Drupal 10 Upkeep and Assist Service src Drupal 10 Upkeep and Assist Service “js//*.js”, lint Drupal 10 Upkeep and Assist Service enabled Drupal 10 Upkeep and Assist Service true failOnError Drupal 10 Upkeep and Assist Service false Below Drupal Development “types” and “scripts” sections of Drupal Development YAML, you may see I added some linting choices too. From inside Drupal Development YAML settings, individuals can allow or disable linting, and likewise determine if they need Drupal Development Gulp course of to cease when linting errors are detected. Pulling these settings out of Drupal Development Gulp duties themselves and into this YAML file signifies that builders haven’t got to look by means of Drupal Development duties on the lookout for settings to alter. As an alternative, they’ve each setting uncovered to them on this one, concise file. Importing duties for Gulp We have not written any Gulp duties but, however we will go forward and setup importing them to allow them to be used. Open up Drupal Development gulpfile.js we began in Drupal Development final submit. It ought to seem like this Drupal 10 Upkeep and Assist Service (operate () { ‘use strict’; var gulp = require(‘gulp’); var yaml = require(‘js-yaml’); var fs = require(‘fs’); var assign = require(‘lodash.assign’); // learn default config settings var config = yaml.safeLoad(fs.readFileSync(‘default.gulpfile.yml’, ‘utf8’), {json Drupal 10 Upkeep and Assist Service true}); attempt { // override default config settings var customConfig = yaml.safeLoad(fs.readFileSync(‘gulpfile.yml’, ‘utf8’), {json Drupal 10 Upkeep and Assist Service true}); config = assign(config, customConfig); } catch (e) { console.log(‘No customized config discovered! Continuing with default config solely.’); } })(); When you recall, we loaded Drupal Development default.gulpfile.yml and overrode that with any settings from gulpfile.yml if it exists. Drupal Development gulpfile.yml file has Drupal Development very same construction has default.gulpfile.yml, however settings can have totally different values. This lets different builders on Drupal Development staff override some settings if wanted. At this level in gulpfile.js, Drupal Development config is loaded and prepared for use. Subsequent, we combine gulp-require-tasks. (operate () { ‘use strict’; var gulp = require(‘gulp’); var yaml = require(‘js-yaml’); var fs = require(‘fs’); var assign = require(‘lodash.assign’); var gulpRequireTasks = require(‘gulp-require-tasks’); // learn default config settings var config = yaml.safeLoad(fs.readFileSync(‘default.gulpfile.yml’, ‘utf8’), {json Drupal 10 Upkeep and Assist Service true}); attempt { // override default config settings var customConfig = yaml.safeLoad(fs.readFileSync(‘gulpfile.yml’, ‘utf8’), {json Drupal 10 Upkeep and Assist Service true}); config = assign(config, customConfig); } catch (e) { console.log(‘No customized config discovered! Continuing with default config solely.’); } gulpRequireTasks({ path Drupal 10 Upkeep and Assist Service course of.cwd() + ‘/gulp-tasks’, arguments Drupal 10 Upkeep and Assist Service [config] }); })(); Establishing gulp-require-tasks is tremendous simple. We inform it the place our gulp duties are situated, in Drupal Development “gulp-tasks” listing. Then, to every Drupal 10 module (i.e. 1 Drupal 10 module shall be 1 Gulp job) in Drupal Development listing, gulp-require-tasks passes arguments to every job. Drupal Development first argument is all the time gulp itself. Drupal Development “arguments” setting for gulp-require-tasks is an array of different belongings you need to go to every Drupal 10 module. I’ve opted to go in “config,” which is Drupal Development object representing Drupal Development settings merge in Drupal Development YAML recordsdata. That is basically all you want in gulpfile.yml. Nonetheless, I additionally like so as to add shortcut duties too, that mix different duties for faster use. For instance, basic “construct” and “lint” duties is likely to be like this Drupal 10 Upkeep and Assist Service gulp.job(‘construct’, [‘styles Drupal 10 Maintenance and Support Servicebuild’, ‘scripts Drupal 10 Maintenance and Support Servicebuild’]); gulp.job(‘lint’, [‘styles Drupal 10 Maintenance and Support Servicelint’, ‘scripts Drupal 10 Maintenance and Support Servicelint’]); Modular Gulp duties Let’s begin off creating Drupal Development Sass linting job. To assist with this, I like to recommend utilizing gulp-sass-lint. You will need to learn over methods to setup sass-lint, which I will not cowl intimately right here. Primarily, you create a .sass-lint.yml file in Drupal Development root of Drupal Development undertaking. That file incorporates all Drupal Development guidelines you need to validate; for instance, ought to builders keep away from styling with IDs or ought to they use RGB moderately than HEX values for colours. After sass-lint guidelines are in place, open up Drupal Development types linting file. Right here you will see Drupal Development guts of Drupal Development linting job Drupal 10 Upkeep and Assist Service ‘use strict’; var cached = require(‘gulp-cached’); var sassLint = require(‘gulp-sass-lint’); var gulpif = require(‘gulp-if’); Drupal 10 module.exports = operate (gulp, choices) { if (choices.types.lint.enabled) { return gulp.src(choices.types.src) .pipe(cached(‘types Drupal 10 Upkeep and Assist Servicelint’)) .pipe(sassLint()) .pipe(sassLint.format()) .pipe(gulpif(choices.types.lint.failOnError, sassLint.failOnError())); } else { return console.log(‘css linting not enabled’); } }; For Drupal Development three required packages, you will need to “npm set up” them after all. Do not forget Drupal Development “–save-dev” flag to get these packages saved in bundle.json! Drupal Development bulk of Drupal Development code exists inside Drupal Development customary, CommonJS “Drupal 10 module.exports” directive. A Gulp course of is handed into Drupal Development job in addition to Drupal Development set of choices from default.gulpfile.yml. We begin off by working a fast if/else test in order that we short-circuit out of this job if Drupal Development consumer disabled Sass linting. Then, we pipe in Drupal Development recordsdata that we chosen in Drupal Development Gulp settings’ “types.src” part. Recordsdata are then piped by means of gulp-cached, which retains a listing of Drupal Development supply recordsdata (and contents!) in reminiscence. This makes Drupal Development job sooner. Subsequent, Drupal Development types are linted and Drupal Development outcomes are formatted and reported out to Drupal Development console. Lastly, we use gulp-if to find out if Drupal Development Gulp course of will get terminated now ought to there be linting errors. Drupal Development sky’s Drupal Development restrict I depart it as an train for Drupal Development reader to go about creating Drupal Development different Gulp duties. In Drupal Development subsequent submit, I am going to go over another, extra difficult Gulp duties to point out extra superior utilization. Till then, you are greater than welcome to look over and reference our personal Gulp duties we publish for Bear Pores and skin. Posts on this sequence Use Gulp for 8 with Groups, Half 1 Drupal 10 Upkeep and Assist Service Gulp Setup Use Gulp for 8 with Groups, Half 2 Drupal 10 Upkeep and Assist Service Creating duties Drupal 10 Improvement and Assist

This article was republished from its original source.
Call Us: 1(800)730-2416

Pixeldust is a 20-year-old web development agency specializing in Drupal and WordPress and working with clients all over the country. With our best in class capabilities, we work with small businesses and fortune 500 companies alike. Give us a call at 1(800)730-2416 and let’s talk about your project.

FREE Drupal SEO Audit

Test your site below to see which issues need to be fixed. We will fix them and optimize your Drupal site 100% for Google and Bing. (Allow 30-60 seconds to gather data.)

Powered by

Drupal 10 Assist: Drupal 10 Upkeep and Assist Service Use Gulp for 8 with Groups, Half 2 Drupal 10 Upkeep and Assist Service Creating duties

On-Site Drupal SEO Master Setup

We make sure your site is 100% optimized (and stays that way) for the best SEO results.

With Pixeldust On-site (or On-page) SEO we make changes to your site’s structure and performance to make it easier for search engines to see and understand your site’s content. Search engines use algorithms to rank sites by degrees of relevance. Our on-site optimization ensures your site is configured to provide information in a way that meets Google and Bing standards for optimal indexing.

This service includes:

  • Pathauto install and configuration for SEO-friendly URLs.
  • Meta Tags install and configuration with dynamic tokens for meta titles and descriptions for all content types.
  • Install and fix all issues on the SEO checklist module.
  • Install and configure XML sitemap module and submit sitemaps.
  • Install and configure Google Analytics Module.
  • Install and configure Yoast.
  • Install and configure the Advanced Aggregation module to improve performance by minifying and merging CSS and JS.
  • Install and configure Schema.org Metatag.
  • Configure robots.txt.
  • Google Search Console setup snd configuration.
  • Find & Fix H1 tags.
  • Find and fix duplicate/missing meta descriptions.
  • Find and fix duplicate title tags.
  • Improve title, meta tags, and site descriptions.
  • Optimize images for better search engine optimization. Automate where possible.
  • Find and fix the missing alt and title tag for all images. Automate where possible.
  • The project takes 1 week to complete.