6 Commits

Author SHA1 Message Date
dependabot[bot]
2818bff1c8 Bump webpack from 5.94.0 to 5.105.0
Bumps [webpack](https://github.com/webpack/webpack) from 5.94.0 to 5.105.0.
- [Release notes](https://github.com/webpack/webpack/releases)
- [Changelog](https://github.com/webpack/webpack/blob/main/CHANGELOG.md)
- [Commits](https://github.com/webpack/webpack/compare/v5.94.0...v5.105.0)

---
updated-dependencies:
- dependency-name: webpack
  dependency-version: 5.105.0
  dependency-type: direct:development
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-02-07 06:20:39 +00:00
Anatoly Kopyl
544ef14295 Merge pull request #28 from anatolykopyl/dependabot/npm_and_yarn/webpack-5.94.0
Bump webpack from 5.76.0 to 5.94.0
2024-09-17 10:05:37 +03:00
dependabot[bot]
218fc0610e Bump webpack from 5.76.0 to 5.94.0
Bumps [webpack](https://github.com/webpack/webpack) from 5.76.0 to 5.94.0.
- [Release notes](https://github.com/webpack/webpack/releases)
- [Commits](https://github.com/webpack/webpack/compare/v5.76.0...v5.94.0)

---
updated-dependencies:
- dependency-name: webpack
  dependency-type: direct:development
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-08-30 10:48:27 +00:00
Anatoly Kopyl
02a46d4908 Merge pull request #27 from anatolykopyl/dependabot/npm_and_yarn/braces-3.0.3
Bump braces from 3.0.2 to 3.0.3
2024-06-19 10:06:12 +03:00
dependabot[bot]
07bcb773f5 Bump braces from 3.0.2 to 3.0.3
Bumps [braces](https://github.com/micromatch/braces) from 3.0.2 to 3.0.3.
- [Changelog](https://github.com/micromatch/braces/blob/master/CHANGELOG.md)
- [Commits](https://github.com/micromatch/braces/compare/3.0.2...3.0.3)

---
updated-dependencies:
- dependency-name: braces
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-06-18 04:12:08 +00:00
b926f0edbf Add eslint 2023-12-10 14:04:02 +03:00
18 changed files with 7140 additions and 962 deletions

1
.gitignore vendored
View File

@@ -4,3 +4,4 @@
/.idea
/assets
.zip
/.vscode

View File

@@ -1,4 +1,7 @@
# vk-mute
[![code style](https://antfu.me/badge-code-style.svg)](https://github.com/antfu/eslint-config)
Заглушить собеседника в беседе в ВК. 🔇
На данный момент ВКонтакте не позволяет заглушать людей в беседах. Это расширение для Chrome берется это исправить.

3
eslint.config.js Normal file
View File

@@ -0,0 +1,3 @@
const antfu = require('@antfu/eslint-config').default
module.exports = antfu()

84
extension/dist/dom.js vendored

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

7291
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -5,7 +5,8 @@
"main": "src/dom/main.js",
"scripts": {
"build": "webpack --config webpack.config.js",
"watch": "webpack --config webpack.config.js --watch"
"watch": "webpack --config webpack.config.js --watch",
"lint": "eslint ."
},
"repository": {
"type": "git",
@@ -18,14 +19,16 @@
},
"homepage": "https://github.com/anatolykopyl/vk-mute#readme",
"devDependencies": {
"@antfu/eslint-config": "^2.4.3",
"@babel/core": "^7.9.0",
"@babel/preset-env": "^7.9.5",
"babel-loader": "^8.3.0",
"css-loader": "^6.7.3",
"eslint": "^8.55.0",
"html-webpack-plugin": "^5.5.0",
"raw-loader": "^4.0.2",
"style-loader": "^1.1.4",
"webpack": "^5.76.0",
"webpack": "^5.105.0",
"webpack-cli": "^4.7.2"
}
}

154
src/dom/controls.js vendored
View File

@@ -1,5 +1,5 @@
import {getChatBody} from "../utils/getChatBody";
import muteSvg from "./mute.svg";
import { getChatBody } from '../utils/getChatBody'
import muteSvg from './mute.svg'
/**
*
@@ -7,12 +7,12 @@ import muteSvg from "./mute.svg";
* @return {HTMLSpanElement}
*/
function muteBtnHTML(id) {
const element = document.createElement('span');
element.setAttribute('class', 'im-mess--mute');
element.setAttribute('id', `mute${id}`);
element.setAttribute('label', 'Заглушить');
element.innerHTML = muteSvg + '<div class="mute_tooltip tt_w tt_black tt_down"><div class="tt_text">Заглушить</div></div>';
return element;
const element = document.createElement('span')
element.setAttribute('class', 'im-mess--mute')
element.setAttribute('id', `mute${id}`)
element.setAttribute('label', 'Заглушить')
element.innerHTML = `${muteSvg}<div class="mute_tooltip tt_w tt_black tt_down"><div class="tt_text">Заглушить</div></div>`
return element
}
/**
@@ -20,10 +20,10 @@ function muteBtnHTML(id) {
* @param target {HTMLElenemt}
*/
export function tryToAddControls(target) {
if (target.className === 'im-mess--check fl_l') {
const message = target.parentElement;
addControlButton(message);
}
if (target.className === 'im-mess--check fl_l') {
const message = target.parentElement
addControlButton(message)
}
}
/**
@@ -33,10 +33,10 @@ export function tryToAddControls(target) {
* @return {HTMLElement}
*/
function addMuteButton(actionArea, senderId) {
const muteButton = muteBtnHTML(senderId);
actionArea.appendChild(muteButton);
muteButton.style.visibility = "hidden";
return muteButton;
const muteButton = muteBtnHTML(senderId)
actionArea.appendChild(muteButton)
muteButton.style.visibility = 'hidden'
return muteButton
}
/**
@@ -44,13 +44,13 @@ function addMuteButton(actionArea, senderId) {
* @param actionsArea {HTMLElement}
*/
function addActionAreaEvents(actionsArea) {
actionsArea.parentElement.addEventListener("mouseenter", function (event) {
event.target.getElementsByClassName("im-mess--mute")[0].style.visibility = "visible";
});
actionsArea.parentElement.addEventListener('mouseenter', (event) => {
event.target.getElementsByClassName('im-mess--mute')[0].style.visibility = 'visible'
})
actionsArea.parentElement.addEventListener("mouseleave", function (event) {
event.target.getElementsByClassName("im-mess--mute")[0].style.visibility = "hidden";
});
actionsArea.parentElement.addEventListener('mouseleave', (event) => {
event.target.getElementsByClassName('im-mess--mute')[0].style.visibility = 'hidden'
})
}
/**
@@ -58,47 +58,44 @@ function addActionAreaEvents(actionsArea) {
* @this {HTMLElement}
*/
function setIdToHideHandle() {
const clickedId = this.id.substring(4);
let clickedName = this.parentElement.parentElement.parentElement.parentElement;
clickedName = clickedName.children[0].children[0].children[0].innerText;
const clickedId = this.id.substring(4)
let clickedName = this.parentElement.parentElement.parentElement.parentElement
clickedName = clickedName.children[0].children[0].children[0].textContent
chrome.storage.sync.get('idsToHide', function(data) {
let idsToHide = data.idsToHide || [];
if (idsToHide.filter(user => user.id == clickedId).length === 0) {
idsToHide.push({
id: clickedId,
name: clickedName
});
chrome.storage.sync.set({idsToHide: idsToHide}, function () {
chrome.storage.sync.get('isExtensionOn', function(data) {
if (data.isExtensionOn) {
hideExistingMessages();
}
});
});
}
});
chrome.storage.sync.get('idsToHide', (data) => {
const idsToHide = data.idsToHide || []
if (idsToHide.filter(user => user.id === clickedId).length === 0) {
idsToHide.push({
id: clickedId,
name: clickedName,
})
chrome.storage.sync.set({ idsToHide }, () => {
chrome.storage.sync.get('isExtensionOn', (data) => {
if (data.isExtensionOn)
hideExistingMessages()
})
})
}
})
}
export function hideExistingMessages() {
chrome.storage.sync.get('idsToHide', function(data) {
const chatBody = getChatBody();
for (let item of chatBody.children) {
if (data.idsToHide.filter(user => user.id == item.dataset.peer).length > 0) {
item.style.display = "none";
}
}
})
chrome.storage.sync.get('idsToHide', (data) => {
const chatBody = getChatBody()
for (const item of chatBody.children) {
if (data.idsToHide.filter(user => user.id === item.dataset.peer).length > 0)
item.style.display = 'none'
}
})
}
// Try to add controls until successful. Needed for page refresh.
export function createTryToInitInterval() {
const controlsInterval = setInterval(function () {
if(!tryToInitControls(controlsInterval)){
clearInterval(controlsInterval);
}
}, 200)
return controlsInterval;
const controlsInterval = setInterval(() => {
if (!tryToInitControls(controlsInterval))
clearInterval(controlsInterval)
}, 200)
return controlsInterval
}
/**
@@ -106,32 +103,33 @@ export function createTryToInitInterval() {
* @param message {HTMLElement}
*/
function addControlButton(message) {
// Check if message is not an outgoing one
if (!message.classList.contains('im-mess_out')) {
const actionsArea = message.getElementsByClassName("im-mess--actions")[0];
if (actionsArea && actionsArea.lastChild.className !== "im-mess--mute") {
const senderId = message.parentElement.parentElement.parentElement["dataset"].peer;
const muteBtn = addMuteButton(actionsArea, senderId);
addActionAreaEvents(actionsArea);
muteBtn.addEventListener("click", setIdToHideHandle);
return true;
} else {
return false;
}
// Check if message is not an outgoing one
if (!message.classList.contains('im-mess_out')) {
const actionsArea = message.getElementsByClassName('im-mess--actions')[0]
if (actionsArea && actionsArea.lastChild.className !== 'im-mess--mute') {
const senderId = message.parentElement.parentElement.parentElement.dataset.peer
const muteBtn = addMuteButton(actionsArea, senderId)
addActionAreaEvents(actionsArea)
muteBtn.addEventListener('click', setIdToHideHandle)
return true
}
else {
return false
}
}
}
export function tryToInitControls() {
let status = true;
const chatBody = getChatBody();
if(!chatBody) return false;
for (let item of chatBody.children) {
if (item.className.includes('im-mess-stack _im_mess_stack')) {
let messages = item.children[1].children[1].getElementsByClassName('im-mess _im_mess');
for (let message of messages) {
status = addControlButton(message);
}
}
let status = true
const chatBody = getChatBody()
if (!chatBody)
return false
for (const item of chatBody.children) {
if (item.className.includes('im-mess-stack _im_mess_stack')) {
const messages = item.children[1].children[1].getElementsByClassName('im-mess _im_mess')
for (const message of messages)
status = addControlButton(message)
}
return status;
}
return status
}

View File

@@ -1,35 +1,35 @@
.mute_tooltip {
position: absolute;
left: -50px;
top: -33px;
display: none;
position: absolute;
left: -50px;
top: -33px;
display: none;
}
.mute_tooltip::after {
left: 61px !important;
left: 61px !important;
}
/* Show the tooltip text when you mouse over the tooltip container */
.im-mess--mute:hover .mute_tooltip {
display: block !important;
opacity: 1;
display: block !important;
opacity: 1;
}
.im-mess--mute {
position: relative;
display: inline-flex;
align-items: center;
justify-content: center;
width: 24px;
height: 24px;
opacity: .5;
color: var(--vkui--color_icon_secondary);
position: relative;
display: inline-flex;
align-items: center;
justify-content: center;
width: 24px;
height: 24px;
opacity: .5;
color: var(--vkui--color_icon_secondary);
}
.im-mess--mute:hover {
opacity: 1;
opacity: 1;
}
.im-mess--actions {
margin-right: -30px !important;
margin-right: -30px !important;
}

View File

@@ -1,58 +1,52 @@
import {getChatBody} from "../utils/getChatBody";
import {tryToAddControls, hideExistingMessages} from "./controls";
import { getChatBody } from '../utils/getChatBody'
import { hideExistingMessages, tryToAddControls } from './controls'
export function addNewMessageEventListener() {
const chatBody = getChatBody();
chatBody.addEventListener('DOMNodeInserted', function(event) {
newMessageHandler(event.target)
});
const chatBody = getChatBody()
chatBody.addEventListener('DOMNodeInserted', (event) => {
newMessageHandler(event.target)
})
}
function newMessageHandler(message) {
tryToAddControls(message);
if (message.className === 'im-mess-stack _im_mess_stack ') {
chrome.storage.sync.get('isExtensionOn', function(data) {
if (data.isExtensionOn) {
chrome.storage.sync.get('idsToHide', function(data) {
if (data.idsToHide.filter(user => user.id == message.dataset.peer).length > 0) {
message.style.display = "none";
}
});
}
});
}
tryToAddControls(message)
if (message.className === 'im-mess-stack _im_mess_stack ') {
chrome.storage.sync.get('isExtensionOn', (data) => {
if (data.isExtensionOn) {
chrome.storage.sync.get('idsToHide', (data) => {
if (data.idsToHide.filter(user => user.id === message.dataset.peer).length > 0)
message.style.display = 'none'
})
}
})
}
}
export function returnMessagesEventListener() {
chrome.storage.onChanged.addListener(function(changes) {
const isExtensionOn = changes.isExtensionOn;
const idsToHide = changes.idsToHide;
const chatBody = getChatBody();
if (isExtensionOn) {
if (isExtensionOn.newValue === false) {
for (let item of chatBody.children) {
item.style.display = "block";
}
} else {
hideExistingMessages();
chrome.storage.onChanged.addListener((changes) => {
const isExtensionOn = changes.isExtensionOn
const idsToHide = changes.idsToHide
const chatBody = getChatBody()
if (isExtensionOn) {
if (isExtensionOn.newValue === false) {
for (const item of chatBody.children)
item.style.display = 'block'
}
else {
hideExistingMessages()
}
}
if (idsToHide) {
chrome.storage.sync.get('isExtensionOn', (data) => {
if (data.isExtensionOn) {
if (idsToHide.newValue.length < idsToHide.oldValue.length) {
for (const item of chatBody.children) {
if (idsToHide.newValue.filter(user => user.id === item.dataset.peer).length === 0)
item.style.display = 'block'
}
}
}
if (idsToHide) {
chrome.storage.sync.get('isExtensionOn', function(data) {
if (data.isExtensionOn) {
if (idsToHide.newValue.length < idsToHide.oldValue.length) {
// for (let item of chatBody.children) {
// item.style.display = "block";
// }
// hideExistingMessages();
for (let item of chatBody.children) {
if (idsToHide.newValue.filter(user => user.id == item.dataset.peer).length === 0) {
item.style.display = "block";
}
}
}
}
});
}
});
})
}
})
}

View File

@@ -1,22 +1,21 @@
import './dom.css'
import {createTryToInitInterval, hideExistingMessages, tryToInitControls} from "./controls";
import {UrlController} from "../utils/Url";
import {addNewMessageEventListener, returnMessagesEventListener} from "./hide_element";
import { UrlController } from '../utils/Url'
import { createTryToInitInterval, hideExistingMessages, tryToInitControls } from './controls'
import { addNewMessageEventListener, returnMessagesEventListener } from './hide_element'
function init() {
const url = new UrlController();
url.onChange(() => {
if (tryToInitControls()) {
createTryToInitInterval();
addNewMessageEventListener();
returnMessagesEventListener();
chrome.storage.sync.get('isExtensionOn', function(data) {
if (data.isExtensionOn) {
hideExistingMessages();
}
});
}
})
const url = new UrlController()
url.onChange(() => {
if (tryToInitControls()) {
createTryToInitInterval()
addNewMessageEventListener()
returnMessagesEventListener()
chrome.storage.sync.get('isExtensionOn', (data) => {
if (data.isExtensionOn)
hideExistingMessages()
})
}
})
}
init();
init()

View File

@@ -1,125 +1,122 @@
* {
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}
body {
min-width: 160px;
margin: 0;
min-width: 160px;
margin: 0;
}
/* The switch - the box around the slider */
.switch {
position: relative;
display: inline-block;
width: 60px;
height: 34px;
position: relative;
display: inline-block;
width: 60px;
height: 34px;
}
/* Hide default HTML checkbox */
.switch input {
opacity: 0;
width: 0;
height: 0;
opacity: 0;
width: 0;
height: 0;
}
/* The slider */
.slider {
position: absolute;
cursor: pointer;
top: 0;
left: 0;
right: 0;
bottom: 0;
background-color: #ccc;
-webkit-transition: .4s;
transition: .4s;
position: absolute;
cursor: pointer;
top: 0;
left: 0;
right: 0;
bottom: 0;
background-color: #ccc;
-webkit-transition: .4s;
transition: .4s;
}
.slider:before {
position: absolute;
content: "";
height: 26px;
width: 26px;
left: 4px;
bottom: 4px;
background-color: white;
-webkit-transition: .4s;
transition: .4s;
position: absolute;
content: "";
height: 26px;
width: 26px;
left: 4px;
bottom: 4px;
background-color: white;
-webkit-transition: .4s;
transition: .4s;
}
input:checked + .slider {
background-color: #2196F3;
background-color: #2196F3;
}
input:focus + .slider {
box-shadow: 0 0 1px #2196F3;
box-shadow: 0 0 1px #2196F3;
}
input:checked + .slider:before {
-webkit-transform: translateX(26px);
-ms-transform: translateX(26px);
transform: translateX(26px);
-webkit-transform: translateX(26px);
-ms-transform: translateX(26px);
transform: translateX(26px);
}
/* Rounded sliders */
.slider.round {
border-radius: 34px;
border-radius: 34px;
}
.slider.round:before {
border-radius: 50%;
border-radius: 50%;
}
.header {
background-color: #2196F3;
color: white;
width: 100%;
height: 3rem;
position: relative;
display: flex;
align-items: center;
justify-content: center;
margin-bottom: 1rem;
background-color: #2196F3;
color: white;
width: 100%;
height: 3rem;
position: relative;
display: flex;
align-items: center;
justify-content: center;
margin-bottom: 1rem;
}
h3 {
margin: 0;
margin: 0;
}
.idToHide {
padding: 10px;
box-sizing: border-box;
display: flex;
justify-content: space-between;
background-color: #fff;
padding: 10px;
box-sizing: border-box;
display: flex;
justify-content: space-between;
background-color: #fff;
}
.idToHide:hover {
background-color: #f1f1f1;
background-color: #f1f1f1;
}
#id_list {
color: black;
position: relative;
width: 100%;
margin-top: 1rem;
color: black;
position: relative;
width: 100%;
margin-top: 1rem;
}
.del_item {
cursor: pointer;
transition: transform 0.2s;
cursor: pointer;
transition: transform 0.2s;
}
.del_item:hover {
transform: scale(1.15);
transform: scale(1.15);
}
.donation_btn {
text-align: right;
margin-top: .5rem;
padding: 0 10px 10px 0;
text-align: right;
margin-top: .5rem;
padding: 0 10px 10px 0;
}
a {
text-decoration: none;
color: hsl(207, 90%, 35%);
text-decoration: none;
color: hsl(207, 90%, 35%);
}

View File

@@ -1,54 +1,51 @@
import './popup.css'
//let disableButton = document.getElementById('disableButton');
const disableCheckbox = document.getElementById('disableCheckbox');
const idsToHideElements = document.getElementsByClassName('idToHide');
const idList = document.getElementById("id_list");
let isExtensionOn;
let idsToHide = [];
const disableCheckbox = document.getElementById('disableCheckbox')
const idsToHideElements = document.getElementsByClassName('idToHide')
const idList = document.getElementById('id_list')
let isExtensionOn
let idsToHide = []
function idBtnHTML(user) {
const element = document.createElement('div');
element.setAttribute('class', 'idToHide');
element.innerHTML = `
const element = document.createElement('div')
element.setAttribute('class', 'idToHide')
element.innerHTML = `
<a href="https://vk.com/id${user.id}" target="_blank" title="Перейти в профиль">🤐 ${user.name}</a>
<span class="del_item" title="Удалить">🗑️</span>
`;
element.id = user.id;
return element;
`
element.id = user.id
return element
}
chrome.storage.sync.get('isExtensionOn', function(data) {
isExtensionOn = data.isExtensionOn;
chrome.storage.sync.get('isExtensionOn', (data) => {
isExtensionOn = data.isExtensionOn
disableCheckbox.checked = isExtensionOn;
});
disableCheckbox.checked = isExtensionOn
})
chrome.storage.sync.get('idsToHide', function(data) {
idsToHide = data.idsToHide;
for (const id in idsToHide) {
const row = idBtnHTML(idsToHide[id]);
idList.appendChild(row);
chrome.storage.sync.get('idsToHide', (data) => {
idsToHide = data.idsToHide
for (const id in idsToHide) {
const row = idBtnHTML(idsToHide[id])
idList.appendChild(row)
}
for (const element of idsToHideElements) {
for (const child of element.childNodes) {
if (child.className === 'del_item') {
child.addEventListener('click', () => {
idsToHide = idsToHide.filter(user => user.id !== element.id)
chrome.storage.sync.set({ idsToHide }, () => {
element.remove()
})
})
}
}
for (const element of idsToHideElements) {
for (const child of element.childNodes) {
if (child.className === "del_item") {
child.addEventListener('click', function() {
idsToHide = idsToHide.filter(user => user.id != element.id);
chrome.storage.sync.set({idsToHide: idsToHide}, function() {
element.remove();
console.log('Cleared idsToHide');
});
});
}
}
};
});
}
})
disableCheckbox.addEventListener('change', (event) => {
isExtensionOn = event.target.checked;
isExtensionOn = event.target.checked
chrome.storage.sync.set({isExtensionOn}, function() {
console.log('isExtensionOn: '+isExtensionOn);
});
});
chrome.storage.sync.set({ isExtensionOn })
})

View File

@@ -1,46 +1,42 @@
const INTERVAL_TIME = 100;
const INTERVAL_TIME = 100
export class UrlController {
constructor() {
this._changeListeners = []
this._interval = null
this._url = window.location.href
}
constructor() {
this._changeListeners = [];
this._interval = null;
this._url = window.location.href;
onChange(cb) {
this._changeListeners.push(cb)
if (this._interval === null)
this._createInterval()
}
removeEventListener(cb) {
this._changeListeners = this._changeListeners.filter(item => item !== cb)
if (this._changeListeners.length === 0)
this._clearInterval()
}
_intervalTick() {
const currentUrl = window.location.href
if (currentUrl !== this.url) {
this._broadcast(this.url, currentUrl)
this.url = currentUrl
}
}
onChange(cb) {
this._changeListeners.push(cb);
if (this._interval === null) {
this._createInterval();
}
}
_broadcast(oldUrl, newUrl) {
this._changeListeners.forEach(cb => cb(oldUrl, newUrl))
}
removeEventListener(cb) {
this._changeListeners = this._changeListeners.filter(item=>item !== cb);
if(this._changeListeners.length === 0) {
this._clearInterval();
}
}
_createInterval() {
this.interval = setInterval(() => this._intervalTick(), INTERVAL_TIME)
}
_intervalTick() {
const currentUrl = window.location.href;
if (currentUrl !== this.url) {
this._broadcast(this.url, currentUrl);
this.url = currentUrl;
}
}
_broadcast(oldUrl, newUrl) {
this._changeListeners.forEach(cb => cb(oldUrl, newUrl));
}
_createInterval() {
this.interval = setInterval(() => this._intervalTick(), INTERVAL_TIME)
}
_clearInterval() {
clearInterval(this.interval)
this.interval = null
}
_clearInterval() {
clearInterval(this.interval)
this.interval = null
}
}

View File

@@ -1,3 +1,3 @@
export function getChatBody() {
return document.getElementsByClassName("_im_peer_history im-page-chat-contain")[0];
return document.getElementsByClassName('_im_peer_history im-page-chat-contain')[0]
}

View File

@@ -1,49 +1,49 @@
const path = require('path');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const path = require('node:path')
const HtmlWebpackPlugin = require('html-webpack-plugin')
module.exports = {
mode: "development",
devtool: "inline-source-map",
entry: {
dom: './src/dom/main.js',
popup: './src/popup/popup.js'
},
output: {
filename: '[name].js',
path: path.resolve(__dirname, 'extension/dist')
},
module: {
rules: [
{
test: /\.m?js$/,
exclude: /(node_modules|bower_components)/,
use: {
loader: 'babel-loader',
options: {
presets: ['@babel/preset-env']
}
}
},
{
test: /\.css$/i,
use: ['style-loader', 'css-loader'],
},
{
test: /\.svg$/i,
use: 'raw-loader',
},
]
},
plugins: [
new HtmlWebpackPlugin({
template: "./src/popup/popup.html",
filename: "popup.html",
chunks: ['popup']
}),
new HtmlWebpackPlugin({
template: "./src/donate.html",
filename: "donate.html",
chunks: ['donate']
})
]
mode: 'development',
devtool: 'inline-source-map',
entry: {
dom: './src/dom/main.js',
popup: './src/popup/popup.js',
},
output: {
filename: '[name].js',
path: path.resolve(__dirname, 'extension/dist'),
},
module: {
rules: [
{
test: /\.m?js$/,
exclude: /(node_modules|bower_components)/,
use: {
loader: 'babel-loader',
options: {
presets: ['@babel/preset-env'],
},
},
},
{
test: /\.css$/i,
use: ['style-loader', 'css-loader'],
},
{
test: /\.svg$/i,
use: 'raw-loader',
},
],
},
plugins: [
new HtmlWebpackPlugin({
template: './src/popup/popup.html',
filename: 'popup.html',
chunks: ['popup'],
}),
new HtmlWebpackPlugin({
template: './src/donate.html',
filename: 'donate.html',
chunks: ['donate'],
}),
],
}