Skip to content

Commit

Permalink
Test with MS Edge, modify build script accordingly
Browse files Browse the repository at this point in the history
  • Loading branch information
rnwst committed Feb 9, 2024
1 parent a1da8c5 commit 1091130
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 10 deletions.
File renamed without changes.
3 changes: 0 additions & 3 deletions browser-profiles/firefox/.gitignore

This file was deleted.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"lint-web-ext": "npm run --silent build && web-ext lint --source-dir dist/firefox",
"start": "npm run --silent start-firefox-desktop",
"start-chromium": "node scripts/build watch chromium",
"start-edge": "node scripts/build watch edge",
"start-firefox-desktop": "node scripts/build watch firefox-desktop",
"start-firefox-android": "node scripts/build watch firefox-android",
"test": "jest --verbose",
Expand Down
29 changes: 22 additions & 7 deletions scripts/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ function getArgs() {
*/
function exitIfIncorrectArgs() {
const args = getArgs();
const browsers = ['chromium', 'firefox-desktop', 'firefox-android'];
const browsers = ['chromium', 'edge', 'firefox-desktop', 'firefox-android'];
if (args.length === 0) return;
if (args.length === 2 && args[0] === 'watch' && browsers.includes(args[1])) {
return;
Expand All @@ -45,7 +45,11 @@ function exitIfIncorrectArgs() {
* @return {string} - Browser-specific distributable directory
*/
function browserDist(browser) {
return path.join(dist, browser === 'chromium' ? 'chromium' : 'firefox');
if (browser === 'edge') browser = 'chromium';
if (['firefox-desktop', 'firefox-android'].includes(browser)) {
browser = 'firefox';
}
return path.join(dist, browser);
}


Expand Down Expand Up @@ -283,7 +287,7 @@ async function buildIcon(icon, size, distDir) {
console.log(
`Converting ${svgIcon} to PNG and writing to dist`);
const png48 =
await svg2png.convert(optimizedSVGStr, {width: size, height: size});
await svg2png.convert(optimizedSVGStr, {width: 300, height: 300});
fs.writeFileSync(path.join(distDir, icon), png48);
}
}
Expand Down Expand Up @@ -363,6 +367,8 @@ function zipDirectory(sourceDir, outPath) {
* @param {boolean} zip - Whether to also zip the built extension
*/
async function build(browser, zip=false) {
if (browser === 'edge') browser = 'chromium';

const manifest = readManifest();
const browserSpecificManifest = adaptManifestToBrowser(manifest, browser);
writeManifest(browserSpecificManifest, browserDist(browser));
Expand Down Expand Up @@ -473,23 +479,32 @@ async function watch(browser) {
// Firefox requires absolute paths.
sourceDir: path.join(process.cwd(), browserDist(browser)),
noReload: true,
target: browser,
target: browser === 'edge' ? 'chromium' : browser,

// Chromium and MS Edge specific options.
...(['chromium', 'edge'].includes(browser) && {
chromiumProfile: `browser-profiles/${browser}`,
}),

...(browser === 'chromium' &&
{chromiumProfile: 'browser-profiles/chromium'}),
// MS Edge specific option.
...(browser === 'edge' &&
{chromiumBinary: '/usr/bin/microsoft-edge-stable'}),

// Firefox specific settings.
...(browser === 'firefox-desktop' && {
// Firefox requires an absolute paths.
firefoxProfile: path.join(process.cwd(), 'browser-profiles/firefox'),
firefox: 'deved',
}),

...(['chromium', 'firefox-desktop'].includes(browser) && {
// Options for all desktop browsers.
...(['chromium', 'edge', 'firefox-desktop'].includes(browser) && {
keepProfileChanges: true,
profileCreateIfMissing: true,
startUrl: 'https://www.youtube.com/watch?v=9G9liRZvi5E',
}),

// Options for Firefox for Android.
...(browser === 'firefox-android' && {
adbDevice: (await adbUtils.listADBDevices())[0],
firefoxApk: 'org.mozilla.fenix',
Expand Down

0 comments on commit 1091130

Please sign in to comment.