I am currently in the process of converting my Chrome pure JS extension into a Vue.js version. The pure JS version works perfectly fine.
However, when using Vue.js, I encounter an error that I can't seem to understand while loading the extension.
Below are my manifest.json and vue.config.js files:
{
"manifest_version": 2,
"name": "__MSG_appName__",
"version": "2.1.0",
"homepage_url": "https://*****.*********/",
"description": "****** Vuejs",
"default_locale": "fr",
"permissions": [
"activeTab",
"<all_urls>",
"*://*/*",
"storage"
],
"icons": {
"48": "icons/icon-48.png",
"64": "icons/icon-64.png",
"128": "icons/icon-128.png"
},
"background": {
"scripts": [
"js/background.js"
],
"persistent": true
},
"browser_action": {
"default_popup": "popup.html",
"default_title": "__MSG_appName__",
"default_icon": {
"48": "icons/icon-48.png",
"64": "icons/icon-64.png"
}
}
}
vue.config.js :
module.exports = {
pages: {
popup: {
template: "public/browser-extension.html",
entry: "./src/popup/main.js",
title: "Popup",
},
},
pluginOptions: {
browserExtension: {
componentOptions: {
background: {
entry: "src/background.js",
},
contentScripts: {
entries: {
"content-script": [
"src/content_scripts/contentScript.js",
"src/content_scripts/config.js",
"src/content_scripts/capture.js",
],
},
},
permissions: [
"<all_urls>",
"activeTab",
"contextMenus",
"notifications",
"storage",
"identity",
],
browser_action: {},
},
},
},
};
The project compiles without any issues. However, when I load my extension in the browser by pointing to the /dist folder, I receive the error Uncaught TypeError: Cannot read properties of undefined (reading 'onClicked') and my extension displays a blank popup. The following code snippet is where the error occurs:
browser.contextMenus.onClicked.addListener(async (info, tab) => {
I have also tried replacing "browser" with "chrome", but without success...
Any assistance would be greatly appreciated. Thank you in advance.