Skip to content

Commit

Permalink
use dynamic manifest config
Browse files Browse the repository at this point in the history
mubaidr committed May 31, 2023
1 parent 743352d commit 358c3d8
Showing 9 changed files with 170 additions and 127 deletions.
1 change: 1 addition & 0 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
module.exports = {
env: {
chrome: true,
browser: true,
es2021: true,
},
44 changes: 44 additions & 0 deletions manifest.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import { defineManifest } from '@crxjs/vite-plugin'
// @ts-ignore
import packageJson from './package.json'

const { version, name } = packageJson
// Convert from Semver (example: 0.1.0-beta6)
const [major, minor, patch, label = '0'] = version
// can only contain digits, dots, or dash
.replace(/[^\d.-]+/g, '')
// split into version parts
.split(/[.-]/)

export default defineManifest(async (env) => ({
name: env.mode === 'staging' ? `[INTERNAL] ${name}` : name,
// up to four numbers separated by dots
version: `${major}.${minor}.${patch}.${label}`,
// semver is OK in "version_name"
version_name: version,
manifest_version: 3,
key: 'ekgmcbpgglflmgcfajnglpbcbdccnnje',
action: {
default_popup: 'src/popup/index.html',
},
background: {
service_worker: 'src/background/index.ts',
},
content_scripts: [
{
all_frames: false,
js: ['src/content-script/index.ts'],
matches: ['*://*/*'],
run_at: 'document_end',
},
],
host_permissions: ['*://*/*'],
options_page: 'src/options/index.html',
permissions: ['storage', 'activeTab', 'identity'],
web_accessible_resources: [
{
matches: ['*://*/*'],
resources: ['src/content-script/index.ts'],
},
],
}))
29 changes: 0 additions & 29 deletions manifest.json

This file was deleted.

30 changes: 22 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
{
"dependencies": {
"vue": "^3.3.4",
"vue-router": "^4.2.1"
"vue-router": "^4.2.2"
},
"devDependencies": {
"@crxjs/vite-plugin": "npm:@crxjs/vite-plugin@beta",
"@crxjs/vite-plugin": "^2.0.0-beta.17",
"@iconify-json/mdi": "^1.1.52",
"@tailwindcss/forms": "^0.5.3",
"@types/chrome": "^0.0.237",
"@types/eslint-config-prettier": "^6.11.0",
"@types/node": "^18.16.16",
"@types/prettier": "^2.7.2",
"@typescript-eslint/eslint-plugin": "^5.59.7",
"@typescript-eslint/parser": "^5.59.7",
"@typescript-eslint/eslint-plugin": "^5.59.8",
"@typescript-eslint/parser": "^5.59.8",
"@vitejs/plugin-vue": "^4.2.3",
"@vueuse/core": "^10.1.2",
"autoprefixer": "^10.4.14",
@@ -25,21 +25,35 @@
"sass": "^1.62.1",
"tailwindcss": "^3.3.2",
"typescript": "^5.0.4",
"unplugin-auto-import": "^0.16.2",
"unplugin-auto-import": "^0.16.4",
"unplugin-icons": "^0.16.1",
"unplugin-vue-components": "^0.24.1",
"unplugin-vue-components": "^0.25.0",
"vite": "^4.3.9",
"vite-plugin-pages": "^0.30.1",
"vue-tsc": "^1.6.5",
"webext-bridge": "^6.0.1"
},
"name": "vite-vue3-chrome-extension-v3",
"overrides": {
"@crxjs/vite-plugin": "$@crxjs/vite-plugin"
},
"pnpm": {
"overrides": {},
"peerDependencyRules": {
"allowAny": [],
"allowedDeprecatedVersions": {
"sourcemap-codec": "1.4.8"
},
"allowedVersions": {},
"ignoreMissing": []
}
},
"private": true,
"scripts": {
"build": "vite build",
"dev": "vite",
"preview": "vite preview",
"lint": "eslint --fix ./src/**/*.{ts,tsx,vue}"
"lint": "eslint --fix ./src/**/*.{ts,tsx,vue}",
"preview": "vite preview"
},
"type": "module",
"version": "0.0.1"
Loading

0 comments on commit 358c3d8

Please sign in to comment.