sp-build-web addBuildTasks function no longer available in drop 6
Category
- [x] Question
- [ ] Typo
- [ ] Bug
- [ ] Enhancement / Suggestion
- [ ] Additional article idea
The following code worked in drop 5 but no longer works in drop 6. It seems the addBuildTasks function was removed from sp-build-web. What is recommended in place of it?
gulpfile.js
const gulp = require('gulp');
const build = require('@microsoft/sp-build-web');
const firsttask = build.subTask('firsttask', (gulp, buildConfig, done) => {
// task code
return Promise.resolve();
});
const secondtask = build.subTask('secondtask', (gulp, buildConfig, done) => {
// task code
return Promise.resolve();
});
build.addBuildTasks(firsttask);
build.addBuildTasks(secondtask);
build.initialize(gulp);
Apologies for not documenting this change. We're working on a big documentation push for the build tools that should give a general explanation of how it all works.
We've recently formalized the concept of a "build rig" in gulp-core-build. The primary build rig for building SPFx-based projects is @microsoft/sp-build-web. A build rig is a collection of sequences of build tasks (like "bundle" and "test"), and related utilities, like addBuildTasks.
As part of the formalization of the rig concept, we did some refactoring of the existing packages, so now addBuildTasks is under the rig export of @microsoft/sp-build-web.
Your gulpfile should look like this:
const gulp = require('gulp');
const build = require('@microsoft/sp-build-web');
const firsttask = build.subTask('firsttask', (gulp, buildConfig, done) => {
// task code
return Promise.resolve();
});
const secondtask = build.subTask('secondtask', (gulp, buildConfig, done) => {
// task code
return Promise.resolve();
});
build.rig.addBuildTasks(firsttask);
build.rig.addBuildTasks(secondtask);
build.initialize(gulp);
@iclanton This was the fix! Thanks for the info!
Issues that have been closed & had no follow-up activity for at least 7 days are automatically locked. Please refer to our wiki for more details, including how to remediate this action if you feel this was done prematurely or in error: Issue List: Our approach to locked issues