Skip to content

Commit 4bb74ab

Browse files
authoredJan 20, 2021
feat: make extension build scripts firefox compatible (#327)
1 parent 14faf06 commit 4bb74ab

File tree

3 files changed

+2188
-69
lines changed

3 files changed

+2188
-69
lines changed
 

‎package-lock.json

+2,167-65
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎package.json

+3
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,12 @@
1717
"start": "run-s start:client",
1818
"start:client": "cross-env NODE_ENV=development node ./scripts/build-client",
1919
"start:devtools": "cross-env NODE_ENV=development node ./scripts/build-devtools",
20+
"start:devtools:firefox": "cross-env NODE_ENV=development BROWSER_ENV=firefox node ./scripts/build-devtools",
2021
"build": "run-s clean build:*",
2122
"build:client": "cross-env NODE_ENV=production node ./scripts/build-client",
2223
"build:server": "cross-env NODE_ENV=production node ./scripts/build-lambda",
2324
"build:devtools": "cross-env NODE_ENV=production node ./scripts/build-devtools",
25+
"build:devtools:firefox": "cross-env NODE_ENV=production BROWSER_ENV=firefox node ./scripts/build-devtools && web-ext build -s ./dist/firefox-extension -a ./dist",
2426
"lint": "run-s lint:*",
2527
"lint:eslint": "eslint . --quiet --fix",
2628
"lint:prettier": "prettier . --write",
@@ -107,6 +109,7 @@
107109
"react-test-renderer": "^16.14.0",
108110
"rimraf": "^3.0.2",
109111
"tailwindcss": "^1.9.6",
112+
"web-ext": "^5.5.0",
110113
"workbox-build": "^5.1.4"
111114
},
112115
"jest": {

‎scripts/build-devtools.js

+18-4
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,17 @@ const { join, resolve } = require('path');
22
const { copy, remove } = require('fs-extra');
33
const { build } = require('./build');
44
const chromeLaunch = require('chrome-launch');
5+
const webExt = require('web-ext');
6+
7+
const isFirefox = process.env.BROWSER_ENV == 'firefox';
58

69
async function main() {
7-
const dest = resolve('dist/chrome-extension');
10+
let dest;
11+
if (isFirefox) {
12+
dest = resolve('dist/firefox-extension');
13+
} else {
14+
dest = resolve('dist/chrome-extension');
15+
}
816
await remove(dest);
917

1018
const parcel = await build({
@@ -31,9 +39,15 @@ async function main() {
3139
);
3240

3341
if (parcel.watching) {
34-
chromeLaunch('https://google.com', {
35-
args: [`--load-extension=${dest}`, '--auto-open-devtools-for-tabs'],
36-
});
42+
if (isFirefox) {
43+
webExt.cmd.run({
44+
sourceDir: dest,
45+
});
46+
} else {
47+
chromeLaunch('https://google.com', {
48+
args: [`--load-extension=${dest}`, '--auto-open-devtools-for-tabs'],
49+
});
50+
}
3751
}
3852
}
3953

0 commit comments

Comments
 (0)
Please sign in to comment.