Skip to content

Commit

Permalink
feat: support manifest v3 (#53)
Browse files Browse the repository at this point in the history
* feat: support manifest v3

* feat: support manifest v2 for firefox
  • Loading branch information
koba04 committed May 31, 2022
1 parent 9ad39d7 commit eb638bf
Show file tree
Hide file tree
Showing 6 changed files with 56 additions and 13 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
node_modules/
dist/
dist-v2/
extension.zip
extension-v2.zip
*.tsbuildinfo
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
"release": "lerna publish --conventional-commits",
"start:demo": "yarn workspace swr-devtools-demo dev",
"start:dev": "yarn workspace swr-devtools start",
"start:extensions": "yarn workspace swr-devtools-extensions start",
"start:panel": "yarn workspace swr-devtools-panel start",
"start": "run-p -l start:*",
"v1": "yarn workspace swr-v1-devtools-demo dev",
Expand Down
29 changes: 29 additions & 0 deletions packages/swr-devtools-extensions/manifest-v2.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
"name": "SWR DevTools",
"description": "A DevTool to inspect your SWR cache",
"version": "0.3.0",
"manifest_version": 2,
"icons": {
"16": "icons/swr-devtools-16.png",
"48": "icons/swr-devtools-48.png",
"64": "icons/swr-devtools-64.png",
"128": "icons/swr-devtools-128.png"
},
"devtools_page": "devtools.html",
"background": {
"scripts": [
"background.js"
]
},
"content_scripts": [
{
"matches": [
"<all_urls>"
],
"js": [
"content.js"
],
"run_at": "document_start"
}
]
}
6 changes: 2 additions & 4 deletions packages/swr-devtools-extensions/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "SWR DevTools",
"description": "A DevTool to inspect your SWR cache",
"version": "0.3.0",
"manifest_version": 2,
"manifest_version": 3,
"icons": {
"16": "icons/swr-devtools-16.png",
"48": "icons/swr-devtools-48.png",
Expand All @@ -11,9 +11,7 @@
},
"devtools_page": "devtools.html",
"background": {
"scripts": [
"background.js"
]
"service_worker": "background.js"
},
"content_scripts": [
{
Expand Down
18 changes: 12 additions & 6 deletions packages/swr-devtools-extensions/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,19 @@
"license": "MIT",
"scripts": {
"prebuild": "yarn clean",
"build:zip": "cd dist && zip -r ../extension.zip * && cd ../",
"build:webpack": "webpack --mode production",
"build": "run-s build:webpack build:zip",
"clean": "rimraf dist/ extension.zip",
"build:zip:chrome": "cd dist && zip -r ../extension.zip * && cd ../",
"build:webpack:chrome": "webpack --mode production",
"build:chrome": "run-s build:webpack:chrome build:zip:chrome",
"build:zip:firefox": "cd dist-v2 && zip -r ../extension-v2.zip * && cd ../",
"build:webpack:firefox": "MANIFEST_VERSION=2 webpack --mode production",
"build:firefox": "run-s build:webpack:firefox build:zip:firefox",
"build": "run-p build:chrome build:firefox",
"clean": "rimraf dist/ dist-v2/ extension.zip",
"lint": "tsc --noEmit",
"start": "webpack --mode development --watch",
"start:firefox": "web-ext run -s dist"
"start:chrome": "webpack --mode development --watch",
"start:firefox:build": "MANIFEST_VERSION=2 webpack --mode development --watch",
"start:firefox:webext": "web-ext run -s dist-v2",
"start:firefox": "run-p start:firefox:*"
},
"devDependencies": {
"@types/chrome": "^0.0.154",
Expand Down
13 changes: 11 additions & 2 deletions packages/swr-devtools-extensions/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@ module.exports = {
devtools: "./src/devtools.ts",
},
output: {
path: path.resolve(__dirname, "dist"),
path: path.resolve(
__dirname,
process.env.MANIFEST_VERSION === "2" ? "dist-v2" : "dist"
),
filename: "[name].js",
},
devtool: "inline-source-map",
Expand All @@ -26,7 +29,13 @@ module.exports = {
new CopyPlugin({
patterns: [
{ from: "src/*.html", to: "[name].html" },
{ from: "manifest.json" },
{
from:
process.env.MANIFEST_VERSION === "2"
? "manifest-v2.json"
: "manifest.json",
to: "manifest.json",
},
{ from: "icons/*.png" },
],
}),
Expand Down

1 comment on commit eb638bf

@vercel
Copy link

@vercel vercel bot commented on eb638bf May 31, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

swr-devtools – ./

swr-devtools-git-main-koba04.vercel.app
swr-devtools-koba04.vercel.app
swr-devtools.vercel.app

Please sign in to comment.