Skip to content

Commit

Permalink
fix: safari build
Browse files Browse the repository at this point in the history
  • Loading branch information
kvhnuke committed Dec 13, 2024
1 parent 416e344 commit 67a01bf
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 2 deletions.
9 changes: 7 additions & 2 deletions packages/extension/configs/vite/transform-manifest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,13 @@ function transFormManifest(): CrxPlugin {
world: 'MAIN',
} as any);
}
if (process.env.BROWSER === 'opera' || process.env.BROWSER === 'safari') {
manifest.permissions?.push('scripting');
if (process.env.BROWSER === 'safari') {
(manifest as any).browser_specific_settings = {
safari: {
strict_min_version: '16.6',
strict_max_version: '18.*',
},
};
}
manifest.web_accessible_resources?.push({
resources: [
Expand Down
30 changes: 30 additions & 0 deletions packages/extension/src/manifest/manifest.safari.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import { defineManifest, ManifestV3Export } from '@crxjs/vite-plugin';
import { chromeManifest } from './manifest.chrome';
const operaManifest = {
...chromeManifest,
action: {
default_icon: {
'16': 'assets/img/safari-icons/icon16.png',
'19': 'assets/img/safari-icons/icon19.png',
'32': 'assets/img/safari-icons/icon32.png',
'38': 'assets/img/safari-icons/icon38.png',
'48': 'assets/img/safari-icons/icon48.png',
'64': 'assets/img/safari-icons/icon64.png',
'72': 'assets/img/safari-icons/icon72.png',
'192': 'assets/img/safari-icons/icon192.png',
},
default_title: 'Enkrypt',
default_popup: 'action.html',
},
host_permissions: ['file://*/*', 'http://*/*', 'https://*/*'],
permissions: [
'storage',
'unlimitedStorage',
'tabs',
'clipboardRead',
'clipboardWrite',
'scripting',
],
} as ManifestV3Export;

export default defineManifest(operaManifest);
3 changes: 3 additions & 0 deletions packages/extension/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { crx } from '@crxjs/vite-plugin';
import chromeManifest from './src/manifest/manifest.chrome';
import firefoxManifest from './src/manifest/manifest.firefox';
import operaManifest from './src/manifest/manifest.opera';
import safariManifest from './src/manifest/manifest.safari';
import assetsRewritePlugin from './configs/vite/assets-rewrite';
import transformManifest from './configs/vite/transform-manifest';
import transformCSInject from './configs/vite/transform-cs-inject';
Expand All @@ -19,6 +20,8 @@ const getManifest = () => {
return firefoxManifest;
case 'opera':
return operaManifest;
case 'safari':
return safariManifest;
default:
return chromeManifest;
}
Expand Down

0 comments on commit 67a01bf

Please sign in to comment.