PlasmoHQ / plasmo

🧩 The Browser Extension Framework
https://www.plasmo.com
MIT License
8.88k stars 316 forks source link

[BUG] $PLASMO_TAG and $PLASMO_BROWSER variables not available in the package.json manifest #920

Open stevebeauge opened 3 months ago

stevebeauge commented 3 months ago

What happened?

Following question https://github.com/PlasmoHQ/plasmo/discussions/919

I need to dynamically define the update_url property of the manifest, depending both on on the tag and the browser.

I expect the plasmo out of the variables, as described in Built-in Environment Variables to be injected into the following string:

"update_url": "https://somewhere.corp.com/$PLASMO_TAG/ourextension-$PLASMO_BROWSER-mv3-$PLASMO_TAG.update.xml"

Providing tag tag1 and browser chrome to plasmo build command, I expect to get this string in the final manifest:

"update_url": "https://somewhere.corp.com/tag1/ourextension-chrome-mv3-tag1.update.xml"

However, the string results in:

"update_url": "https://somewhere.corp.com/$PLASMO_TAG/ourextension-$PLASMO_BROWSER-mv3-$PLASMO_TAG.update.xml"

Variables from the .env files are ok in my actual project.

As a workaround, I can define myself the variables using a build script:

"build" : "cross-env PLASMO_TAG=tag1 PLASMO_BROWSER=chrome plasmo build --target=chrome-mv3 --tag=tag1

In this case, the resulting string is OK.

FYI, I'm working on W10, using plasmo 0.83 (latest version does not build because of incorrect icon.png handling.

Version

Latest

What OS are you seeing the problem on?

Windows

What browsers are you seeing the problem on?

Chrome, Microsoft Edge

Relevant log output

🟑 0      | Running command: build
🟣 Plasmo v0.83.1
πŸ”΄ The Browser Extension Framework
🟠 WARN   | A new version of plasmo is available: v0.85.2
          | Run "pnpm i plasmo@0.85.2" to update
πŸ”΅ INFO   | Prepare to bundle the extension...
🟑 1      | Creating Manifest Factory...
🟑 2      | Loaded env from .env.dev
🟑 3      | Ensure exists: c:\path\to\myextension\.plasmo
🟑 4      | c:\path\to\myextension\assets\icon.png found, creating resized icons
🟑 5      | Loaded env from .env.dev
🟑 6      | Creating static templates for popup
🟑 7      | Creating static templates for options
🟑 8      | Creating static templates for newtab
🟑 9      | Creating static templates for devtools
🟑 10     | Creating static templates for sidepanel
🟑 11     | Creating page mount template for tabs
🟑 12     | Parsed config: { matches: [ '<all_urls>' ], world: 'MAIN' }
🟑 13     | Adding content script:  c:\path\to\myextension\src\contents\MainWorld.ts
🟑 14     | Adding content script:  c:\path\to\myextension\src\contents\TriggerSearchButton.ts
🟑 15     | { messageHandlerList: [], portHandlerList: [] }
🟑 16     | Creating BGSW entry
🟑 17     | Hash changed, updating manifest
πŸ”΅ INFO   | Loaded environment variables from: [ '.env.dev' ]
🟑 0      | @plasmohq/parcel-transformer-manifest
🟑 1      | Adding tab modalhost.tsx
🟑 2      | Adding tab modalhost.html
🟑 3      | Adding icons
🟑 4      | Adding default_icon
🟑 5      | Adding default_popup
🟑 6      | Handling background scripts
🟑 7      | Handling background service worker
🟑 0      | @plasmohq/parcel-bundler
🟑 0      | @plasmohq/parcel-packager
🟑 0      | @plasmohq/parcel-optimizer-encapsulate NestedAppAuthController.b32b4372.js NestedAppAuthController.[hash].js
🟑 1      | @plasmohq/parcel-optimizer-encapsulate tabs\modalhost.46cc4181.js tabs\modalhost.[hash].js
🟑 2      | @plasmohq/parcel-optimizer-encapsulate popup.0c24dd77.js popup.[hash].js
🟑 3      | @plasmohq/parcel-optimizer-encapsulate static\background\index.js static\background\index.js
🟑 0      | @plasmohq/parcel-optimizer-encapsulate tabs\modalhost.50eb5ebb.js tabs\modalhost.[hash].js
🟑 0      | @plasmohq/optimizer-es:  NestedAppAuthController.b32b4372.js NestedAppAuthController.[hash].js c:\path\to\myextension
🟑 1      | @plasmohq/optimizer-es:  tabs\modalhost.46cc4181.js tabs\modalhost.[hash].js c:\path\to\myextension
🟑 2      | @plasmohq/optimizer-es:  popup.0c24dd77.js popup.[hash].js c:\path\to\myextension
🟑 3      | @plasmohq/optimizer-es:  static\background\index.js static\background\index.js c:\path\to\myextension
🟑 4      | optimizer-es: use SWC for NestedAppAuthController.[hash].js
🟑 5      | optimizer-es: use SWC for tabs\modalhost.[hash].js
🟑 6      | optimizer-es: use SWC for popup.[hash].js
🟑 7      | optimizer-es: use SWC for static\background\index.js
🟑 1      | @plasmohq/parcel-optimizer-encapsulate BPGFTGZB.e29f5f05.js BPGFTGZB.[hash].js
🟑 2      | @plasmohq/parcel-optimizer-encapsulate popup.6f7cb207.js popup.[hash].js
🟑 3      | @plasmohq/parcel-optimizer-encapsulate MainWorld.7fc89055.js MainWorld.[hash].js
🟑 0      | @plasmohq/optimizer-es:  tabs\modalhost.50eb5ebb.js tabs\modalhost.[hash].js c:\path\to\myextension
🟑 1      | @plasmohq/optimizer-es:  BPGFTGZB.e29f5f05.js BPGFTGZB.[hash].js c:\path\to\myextension
🟑 2      | @plasmohq/optimizer-es:  popup.6f7cb207.js popup.[hash].js c:\path\to\myextension
🟑 3      | @plasmohq/optimizer-es:  MainWorld.7fc89055.js MainWorld.[hash].js c:\path\to\myextension
🟑 4      | optimizer-es: use SWC for tabs\modalhost.[hash].js
🟑 5      | optimizer-es: use SWC for BPGFTGZB.[hash].js
🟑 6      | optimizer-es: use SWC for popup.[hash].js
🟑 7      | optimizer-es: use SWC for MainWorld.[hash].js
🟑 4      | @plasmohq/parcel-optimizer-encapsulate TriggerSearchButton.be12c79d.js TriggerSearchButton.[hash].js
🟑 8      | @plasmohq/optimizer-es:  TriggerSearchButton.be12c79d.js TriggerSearchButton.[hash].js c:\path\to\myextension
🟑 9      | optimizer-es: use SWC for TriggerSearchButton.[hash].js
🟒 DONE   | Finished in 29635ms!
πŸ”΅ INFO   | Zip Package size: 5.75 MB in 2381ms

(OPTIONAL) Contribution

Code of Conduct