2017-10-27 11:14:14 -04:00
|
|
|
'use strict';
|
|
|
|
|
|
|
|
const gulp = require('gulp');
|
2018-08-07 10:27:46 -04:00
|
|
|
const path = require('path');
|
2017-10-27 11:14:14 -04:00
|
|
|
const build = require('@microsoft/sp-build-web');
|
2018-08-07 10:27:46 -04:00
|
|
|
const bundleAnalyzer = require('webpack-bundle-analyzer');
|
2017-10-27 11:14:14 -04:00
|
|
|
|
2018-07-02 05:44:04 -04:00
|
|
|
/********************************************************************************************
|
|
|
|
* Adds an alias for handlebars in order to avoid errors while gulping the project
|
|
|
|
* https://github.com/wycats/handlebars.js/issues/1174
|
|
|
|
* Adds a loader and a node setting for webpacking the handlebars-helpers correctly
|
|
|
|
* https://github.com/helpers/handlebars-helpers/issues/263
|
|
|
|
********************************************************************************************/
|
|
|
|
build.configureWebpack.mergeConfig({
|
|
|
|
additionalConfiguration: (generatedConfiguration) => {
|
|
|
|
|
|
|
|
generatedConfiguration.resolve.alias = { handlebars: 'handlebars/dist/handlebars.min.js' };
|
|
|
|
|
|
|
|
generatedConfiguration.module.rules.push(
|
|
|
|
{
|
|
|
|
test: /utils\.js$/,
|
|
|
|
loader: 'unlazy-loader',
|
|
|
|
include: [
|
|
|
|
/node_modules/,
|
|
|
|
]
|
|
|
|
}
|
|
|
|
);
|
|
|
|
|
|
|
|
generatedConfiguration.node = {
|
|
|
|
fs: 'empty'
|
|
|
|
}
|
2018-08-07 10:27:46 -04:00
|
|
|
|
|
|
|
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'
|
|
|
|
}));
|
2018-07-02 05:44:04 -04:00
|
|
|
|
|
|
|
return generatedConfiguration;
|
|
|
|
}
|
|
|
|
});
|
2018-09-24 07:27:49 -04:00
|
|
|
build.webpack.buildConfig
|
|
|
|
build.addSuppression(`Warning - [sass] The local CSS class 'ms-Grid' is not camelCase and will not be type-safe.`);
|
2018-08-07 10:27:46 -04:00
|
|
|
|
2017-10-27 11:14:14 -04:00
|
|
|
build.initialize(gulp);
|