const elementReady = (parent, selector) => {
return new Promise(resolve => {
let el = parent.querySelector(selector)
if (el) {
resolve(el)
}
new MutationObserver((mutationRecords, observer) => {
// Query for elements matching the specified selector
Array.from(parent.querySelectorAll(selector)).forEach(element => {
resolve(element)
// Once we have resolved we don`t need the observer anymore.
observer.disconnect()
})
}).observe(parent.documentElement, {
childList: true,
subtree: true,
})
})
}
function excludeNodeModulesExcept(modules) {
var pathSep = path.sep
if (pathSep == '\\')
pathSep = '\\\\'
var moduleRegExps = modules.map(function (modName) {
return new RegExp('node_modules' + pathSep + modName)
})
return function (modulePath) {
if (/node_modules/.test(modulePath)) {
for (var i = 0; i < moduleRegExps.length; i++)
if (moduleRegExps[i].test(modulePath)) return false
return true
}
return false
}
}
rules: [
{
test: /\.js$/,
// Сюда передаём название нужного модуля.
exclude: excludeNodeModulesExcept(['your_module']),
use: {
loader: `babel-loader`,
},
},
]
const buttonItems = document.querySelectorAll('.button-item');
for (let buttonItem of buttonItems) {
buttonItem.addEventListener('click', (e) => e.preventDefault());
}
const buttonItems = document.querySelectorAll('.button-item');
buttonItems.forEach((buttonItem) => buttonItem.addEventListener('click', (e) => e.preventDefault());