Skip to content

Commit

Permalink
feat: support chrome extension
Browse files Browse the repository at this point in the history
  • Loading branch information
Heroor committed Apr 25, 2024
1 parent d709b71 commit 9cf5eea
Show file tree
Hide file tree
Showing 6 changed files with 82 additions and 4 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ lerna-debug.log*
node_modules
dist
dist-ssr
/extension
*.local

# Editor directories and files
Expand Down
6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "hello-nav",
"version": "1.0.0-beta.1",
"version": "1.0.0",
"author": "Bener",
"private": true,
"license": "MIT",
Expand All @@ -12,6 +12,7 @@
"scripts": {
"dev": "vite",
"build": "tsc && vite build",
"build:ext": "npm run build && node ./scripts/build-ext.mjs",
"preview": "vite preview",
"lint": "prettier --write ."
},
Expand All @@ -31,6 +32,7 @@
"prettier": "^3.2.5",
"typescript": "^4.6.3",
"vite": "^2.9.16",
"vite-plugin-glob": "^0.3.2"
"vite-plugin-glob": "^0.3.2",
"zx": "^8.0.2"
}
}
43 changes: 43 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions public/manifest.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "hello nav",
"short_name": "nav",
"name": "Hello Nav",
"short_name": "Hello Nav",
"icons": [
{
"src": "/favicon/favicon-36.png",
Expand Down
18 changes: 18 additions & 0 deletions scripts/build-ext.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { resolve, dirname } from 'node:path'
import { fileURLToPath } from 'node:url'
import 'zx/globals'

const __filename = fileURLToPath(import.meta.url)
const __dirname = dirname(__filename)

const extensionDir = resolve(__dirname, '../src/extension')
const distDir = resolve(__dirname, '../dist')
const outputDir = resolve(__dirname, '../extension')

await $`mkdir -p ${outputDir}`
await $`rm -rf ${outputDir}/*`

await $`cp -r ${distDir}/* ${outputDir}`
await $`cp -rf ${extensionDir}/* ${outputDir}`

console.log('🧩 Extension generation success!')
14 changes: 14 additions & 0 deletions src/extension/manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"name": "Hello Nav",
"description": "A navigation for developer.",
"version": "1.0.0",
"chrome_url_overrides": {
"newtab": "index.html"
},
"icons": {
"16": "./favicon/favicon-512.png",
"48": "./favicon/favicon-512.png",
"128": "./favicon/favicon-512.png"
},
"manifest_version": 3
}

0 comments on commit 9cf5eea

Please sign in to comment.