-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathgulpfile.js
50 lines (38 loc) · 1.7 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
//@ts-check
'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.configureWebpack.mergeConfig({
additionalConfiguration: (generatedConfiguration) => {
// When creating a production build...
if (process.argv.indexOf('--ship') > -1 || process.argv.indexOf('-s') > -1) {
// Create a stats folder and put generated webpack stats within it.
const path = require('path');
const bundleAnalyzer = require('webpack-bundle-analyzer');
const lastDirName = path.basename(__dirname);
const dropPath = path.join(__dirname, 'temp', 'stats');
generatedConfiguration.plugins.push(
new bundleAnalyzer.BundleAnalyzerPlugin({
openAnalyzer: false,
analyzerMode: 'static',
reportFilename: path.join(dropPath, `${lastDirName}.stats.html`),
generateStatsFile: true,
statsFilename: path.join(dropPath, `${lastDirName}.stats.json`),
logLevel: 'error'
})
);
}
// Force use of projects specified react version.
// @see https://inprod.dev/blog/2020-02-12-spfx-sharepoint-server-2019/
// Necessary for `react-testing-library` to use `waitFor utilities, which require `react-dom@16.9.0`.
generatedConfiguration.externals = generatedConfiguration.externals.filter((name) => !['react', 'react-dom'].includes(name));
return generatedConfiguration;
}
});
build.initialize(require('gulp'));