-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
52 lines (34 loc) · 2.48 KB
/
gulpfile.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
'use strict';
const gulp = require('gulp');
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;
};
/* fast-serve */
const { addFastServe } = require("spfx-fast-serve-helpers");
addFastServe(build);
/* end of fast-serve */
build.initialize(require('gulp'));
// This function updates the package-solution version analogue to the the package.json file.
gulp.task('version-sync', function (done) { // Create gulp task: 'version-sync'
const gutil = require('gulp-util'); // Import gulp utilits to write error messages
const fs = require('fs'); // Import file system utilities from nodeJS
var pkgConfig = require('./package.json'); // Read package.json
var pkgSolution = require('./config/package-solution.json'); // Read configuration of spfx web part solution file
gutil.log('Syncing versions…');
var newVersionNumber = pkgConfig.version.split('-')[0] + '.0'; // Generate new MS compliant version number
if (pkgSolution.solution.version !== newVersionNumber) {
gutil.log('From old version:', gutil.colors.yellow(pkgSolution.solution.version), 'to new:', gutil.colors.yellow(newVersionNumber)); // Log old to new version
pkgSolution.solution.version = newVersionNumber; // Assign newly generated version number to web part version
fs.writeFile('./config/package-solution.json', JSON.stringify(pkgSolution, null, 4), { "encoding": "utf8" }, function (err) { // Write changed package-solution file
if (err) gutil.log('Error:', err);
});
} else {
gutil.log('Versions are up to date');
}
done();
});