kopia lustrzana https://github.com/wagtail/wagtail
Add custom webpack loader to reduce polyfills in axe code
rodzic
0a8c121437
commit
a80d8e449a
|
@ -0,0 +1,9 @@
|
|||
export default function replaceAllLoader(source) {
|
||||
const options = this.getOptions();
|
||||
const { replace } = options;
|
||||
let newSource = source;
|
||||
Object.entries(replace).forEach(([oldString, newString]) => {
|
||||
newSource = newSource.replaceAll(oldString, newString);
|
||||
});
|
||||
return newSource;
|
||||
}
|
|
@ -196,6 +196,22 @@ module.exports = function exports(env, argv) {
|
|||
loader: 'ts-loader',
|
||||
exclude: /node_modules/,
|
||||
},
|
||||
{
|
||||
test: /axe\.js$/,
|
||||
loader: path.resolve(__dirname, 'string-replaceall-loader.js'),
|
||||
options: {
|
||||
replace: {
|
||||
"!('hasOwn' in Object)": 'false',
|
||||
"!('values' in Object)": 'false',
|
||||
"!('Promise' in window)": 'false',
|
||||
"!('Uint32Array' in window)": 'false',
|
||||
"!('some' in window.Uint32Array.prototype)": 'false',
|
||||
"!('reduce' in window.Uint32Array.prototype)": 'false',
|
||||
"typeof Object.assign !== 'function'": 'false',
|
||||
'if (!Array.from)': 'if (false)',
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
test: /\.(svg)$/i,
|
||||
type: 'asset/inline',
|
||||
|
|
Ładowanie…
Reference in New Issue