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');
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 ;
}
if(needIESupport){
process.stdout.write(`Using babel-loader to support IE11 \n`);
build.configureWebpack.mergeConfig({
additionalConfiguration: (generatedConfiguration) => {
generatedConfiguration.module.rules.push({
test: /\.js$/,
exclude: /node_modules\/(?!(rss-paser))/,
use: {
loader: 'babel-loader',
options: {
presets: [
["@babel/preset-env",
{
targets: {
"ie": "11"
}
build.configureWebpack.mergeConfig({
additionalConfiguration: (generatedConfiguration) => {
generatedConfiguration.module.rules.push({
test: /\.js$/,
exclude: /node_modules\/(?!(rss-paser|@babel))/,
use: {
loader: 'babel-loader',
options: {
presets: [
["@babel/preset-env",
{
targets: {
"ie": "11"
}
}
]
]
]
}
}
}
});
return generatedConfiguration;
}
});
/*
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;
}
});
*/
});
return generatedConfiguration;
}
});
} else {
process.stdout.write(`No IE11 Support webpack will be 5 times faster \n`);
}
build.initialize(gulp);