solution with parameter

This commit is contained in:
petkir 2020-07-15 00:25:11 +02:00
parent 347d94a1cd
commit 98148a63d4
1 changed files with 32 additions and 41 deletions

View File

@ -4,51 +4,42 @@ const gulp = require('gulp');
const build = require('@microsoft/sp-build-web'); 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.addSuppression(`Warning - [sass] The local CSS class 'ms-Grid' is not camelCase and will not be type-safe.`);
let needIESupport = true;
if(!!process.argv && process.argv.length >0) {
needIESupport = process.argv.findIndex(item => '--noie11' === item.toLowerCase()) !=-1 ;
}
build.configureWebpack.mergeConfig({
additionalConfiguration: (generatedConfiguration) => { if(needIESupport){
generatedConfiguration.module.rules.push({ process.stdout.write(`Using babel-loader to support IE11 \n`);
test: /\.js$/, build.configureWebpack.mergeConfig({
exclude: /node_modules\/(?!(rss-paser|@babel))/, additionalConfiguration: (generatedConfiguration) => {
use: { generatedConfiguration.module.rules.push({
loader: 'babel-loader', test: /\.js$/,
options: { exclude: /node_modules\/(?!(rss-paser))/,
presets: [ use: {
["@babel/preset-env", loader: 'babel-loader',
{ options: {
targets: { presets: [
"ie": "11" ["@babel/preset-env",
{
targets: {
"ie": "11"
}
} }
} ]
] ]
] }
} }
} });
});
return generatedConfiguration;
return generatedConfiguration; }
} });
}); } else {
process.stdout.write(`No IE11 Support webpack will be 5 times faster \n`);
/* }
Show current Webpack configuration
*/
/*
build.configureWebpack.mergeConfig({
additionalConfiguration: (generatedConfig) => {
console.log('<webpack.config type="object">');
console.log(generatedConfig);
console.log('</webpack.config>');
console.log('<webpack.config type="string">');
console.log(JSON.stringify(generatedConfig));
console.log('</webpack.config>');
return generatedConfig;
}
});
*/
build.initialize(gulp); build.initialize(gulp);