Invalid TARGET Option for multibrowser support
Closed this issue · 3 comments
Summary
When using the TARGET=
option for multibrowser support, the execution fails. This command is used in the package.json
to define the target browser.
Many demos in the official repository utilize it (see e.g. demo-vue):
"build:firefox": "TARGET=firefox vite build --mode production"
Related documentation page: Multibrowser Support - Manifest Templates
The error:
'TARGET' is not recognized as an internal or external command,
operable program or batch file.
ELIFECYCLE Command failed with exit code 1.
Reproduction (using one of the example projects)
Clone this repository:
git clone https://github.com/aklinker1/vite-plugin-web-extension.git
Navigate to one of the sample projects:
cd .\packages\demo-vue
Run the failing command:
pnpm run build:firefox
Environment
System:
OS: Windows 11 10.0.22631
CPU: (16) x64 AMD Ryzen 7 7800X3D 8-Core Processor
Memory: 17.47 GB / 31.21 GB
Binaries:
Node: 20.10.0 - C:\Program Files\nodejs\node.EXE
npm: 10.2.5 - C:\Program Files\nodejs\npm.CMD
pnpm: 8.12.1 - ~\AppData\Roaming\npm\pnpm.CMD
bun: 1.0.18 - ~\.bun\bin\bun.EXE
Browsers:
Edge: Chromium (120.0.2210.91)
Internet Explorer: 11.0.22621.1
npmPackages:
vite: ^5.0.0 => 5.0.2
vite-plugin-web-extension: workspace:* => 4.1.0
@GODrums This is how you set an environment variable in Linux/Mac, it doesn't work on Windows, at least not in CMD and Powershell. It works with WSL and git bash.
Solution: cross-env
pnpm i cross-env
- "dev:firefox": "TARGET=Firefox vite",
+ "dev:firefox": "cross-env TARGET=Firefox vite",
I can add a section to the docs with this info.
Thank you for the extensive explanation! Your suggested solution works exactly as intented.
I would love a short section about this for us Windows users, although I probably should have been able to figure this out myself.