diff --git a/.env.development b/.env.development new file mode 100644 index 0000000..8ed0e6b --- /dev/null +++ b/.env.development @@ -0,0 +1 @@ +VITE_API_URL=http://localhost:5000 diff --git a/.env.production b/.env.production new file mode 100644 index 0000000..cf2d573 --- /dev/null +++ b/.env.production @@ -0,0 +1 @@ +VITE_API_URL=https://ariadne.dantis.me diff --git a/.github/workflows/build-extension.yml b/.github/workflows/build-extension.yml index daed2a9..c5d2650 100644 --- a/.github/workflows/build-extension.yml +++ b/.github/workflows/build-extension.yml @@ -16,7 +16,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout repository - uses: actions/checkout@v2 + uses: actions/checkout@v3 - name: Install dependencies run: npm ci - name: Build extension (Manifest V2) @@ -29,5 +29,4 @@ jobs: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: file: "web-ext-artifacts/*.zip" - tags: true if: github.event_name != 'pull_request' diff --git a/background/background.js b/background/background.js index 2b2dd4d..9ef75b2 100644 --- a/background/background.js +++ b/background/background.js @@ -4,24 +4,15 @@ class AriadneBackground { constructor() { this._tabStates = []; this._reportStats = {}; - this._API_URL = 'https://ariadne.dantis.me/api/v1'; - - // Determine if running in unpacked mode - const that = this; - browser.management.get(browser.runtime.id) - .then((extensionInfo) => { - if (extensionInfo.installType === 'development') { - console.log('[bg] Running in development mode'); - that._API_URL = 'http://localhost:5000/api/v1'; - } - that.addListeners(); - }); + this._API_URL = import.meta.env.VITE_API_URL + '/api/v1'; // Alias if browser.action is defined, i.e. in Manifest V3 this.BrowserAction = browser.browserAction; if (browser.action !== undefined) { this.BrowserAction = browser.action; } + + this.addListeners(); } addListeners() { diff --git a/package.json b/package.json index c6efc53..373a480 100644 --- a/package.json +++ b/package.json @@ -9,14 +9,17 @@ "url": "https://github.com/wsg-ariadne/ariadne" }, "scripts": { - "dev": "vite", + "dev:bg": "vite build -m development --config vite.bg.config.js", + "dev:content": "vite build -m development --config vite.content.config.js", + "dev:main": "vite build -m development", + "dev": "for TARGET in main bg content; do npm run dev:$TARGET; done", + "dev:v3": "npm run dev && mv dist/manifest.v3.json dist/manifest.json", "build:bg": "vite build --config vite.bg.config.js", "build:content": "vite build --config vite.content.config.js", "build:main": "vite build", "build": "for TARGET in main bg content; do NODE_ENV=production npm run build:$TARGET; done", - "build:v3": "npm run build && mv dist/manifest.v3.json dist/manifest.json", - "package": "npm run build && web-ext build --overwrite-dest --source-dir dist --ignore-files \"**/manifest.v3.json\"", - "package:v3": "npm run build:v3 && web-ext build --overwrite-dest --source-dir dist" + "package": "npm run build && mv dist/manifest.v3.json dist/manifest.json && web-ext build --overwrite-dest --source-dir dist --ignore-files \"**/manifest.v3.json\"", + "package:v3": "npm run build && web-ext build --overwrite-dest --source-dir dist" }, "dependencies": { "@heroicons/vue": "^2.0.16", diff --git a/public/manifest.json b/public/manifest.json index ea9c7cf..2a4a322 100644 --- a/public/manifest.json +++ b/public/manifest.json @@ -7,8 +7,7 @@ "manifest_version": 2, "default_locale": "en", "permissions": [ - "tabs", - "management" + "tabs" ], "optional_permissions": [ "" diff --git a/public/manifest.v3.json b/public/manifest.v3.json index 356a412..dd8cc4f 100644 --- a/public/manifest.v3.json +++ b/public/manifest.v3.json @@ -9,8 +9,7 @@ "default_locale": "en", "minimum_chrome_version": "88", "permissions": [ - "tabs", - "management" + "tabs" ], "icons": { "128": "assets/img/Button@8x.png"