Sunday 6 February 2022

Task never defined: serve SPFX upgrade

Problem - After upgrading spfx project you will see the problem when executing gulp serve. 

Solution -  upgrade gulpfile.js serve refrence.


Gulp version - 3.xxx

'use strict';


const build = require('@microsoft/sp-build-web');

build.addSuppression(`Warning - [sass] The local CSS class 'ms-Grid' is not camelCase and will not be type-safe.`);

build.initialize(require('gulp'));


Upgrade gulp v4.0xxx

 'use strict';


const build = require('@microsoft/sp-build-web');

build.addSuppression(`Warning - [sass] The local CSS class 'ms-Grid' is not camelCase and will not be type-safe.`);

var getTasks = build.rig.getTasks;
build.rig.getTasks = function () {
  var result = getTasks.call(build.rig);

  result.set('serve'result.get('serve-deprecated'));

  return result;
};

build.initialize(require('gulp'));