Skip to content

Commit

Permalink
Add 'with-browser-specific-overrides' example. (#67)
Browse files Browse the repository at this point in the history
  • Loading branch information
tbrockman authored Aug 26, 2024
1 parent 71dc225 commit 62613fa
Show file tree
Hide file tree
Showing 7 changed files with 191 additions and 0 deletions.
33 changes: 33 additions & 0 deletions with-browser-specific-overrides/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@

# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.

# dependencies
/node_modules
/.pnp
.pnp.js

# testing
/coverage

# misc
.DS_Store
*.pem

# debug
npm-debug.log*
yarn-debug.log*
yarn-error.log*
.pnpm-debug.log*

# local env files
.env*.local

out/
build/
dist/

# plasmo
.plasmo

# typescript
.tsbuildinfo
26 changes: 26 additions & 0 deletions with-browser-specific-overrides/.prettierrc.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/**
* @type {import('prettier').Options}
*/
export default {
printWidth: 80,
tabWidth: 2,
useTabs: false,
semi: false,
singleQuote: false,
trailingComma: "none",
bracketSpacing: true,
bracketSameLine: true,
plugins: ["@ianvs/prettier-plugin-sort-imports"],
importOrder: [
"<BUILTIN_MODULES>", // Node.js built-in modules
"<THIRD_PARTY_MODULES>", // Imports not matched by other special words or groups.
"", // Empty line
"^@plasmo/(.*)$",
"",
"^@plasmohq/(.*)$",
"",
"^~(.*)$",
"",
"^[./]"
]
}
33 changes: 33 additions & 0 deletions with-browser-specific-overrides/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
This is a [Plasmo extension](https://docs.plasmo.com/) project bootstrapped with [`plasmo init`](https://www.npmjs.com/package/plasmo).

## Getting Started

First, run the development server:

```bash
pnpm dev
# or
npm run dev
```

Open your browser and load the appropriate development build. For example, if you are developing for the chrome browser, using manifest v3, use: `build/chrome-mv3-dev`.

You can start editing the popup by modifying `popup.tsx`. It should auto-update as you make changes. To add an options page, simply add a `options.tsx` file to the root of the project, with a react component default exported. Likewise to add a content page, add a `content.ts` file to the root of the project, importing some module and do some logic, then reload the extension on your browser.

For further guidance, [visit our Documentation](https://docs.plasmo.com/)

## Making production build

Run the following:

```bash
pnpm build
# or
npm run build
```

This should create a production bundle for your extension, ready to be zipped and published to the stores.

## Submit to the webstores

The easiest way to deploy your Plasmo extension is to use the built-in [bpp](https://bpp.browser.market) GitHub action. Prior to using this action however, make sure to build your extension and upload the first version to the store to establish the basic credentials. Then, simply follow [this setup instruction](https://docs.plasmo.com/framework/workflows/submit) and you should be on your way for automated submission!
Binary file added with-browser-specific-overrides/assets/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
17 changes: 17 additions & 0 deletions with-browser-specific-overrides/background.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { generateMnemonic } from "bip39"

console.log(
"Live now; make now always the most precious time. Now will never come again."
)

chrome.action.onClicked.addListener(() => {
console.log(`action clicked: ${generateMnemonic()}`)
})

chrome.commands.onCommand.addListener((command) => {
if (command === "test") {
console.log(`test command: ${generateMnemonic()}`)
} else if (command === "test-chrome") {
console.log(`chrome specific command: ${generateMnemonic()}`)
}
})
63 changes: 63 additions & 0 deletions with-browser-specific-overrides/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
{
"name": "with-browser-specific-overrides",
"displayName": "With browser specific overrides",
"version": "0.0.1",
"description": "A basic Plasmo extension.",
"author": "Theodore Brockman <[email protected]>",
"contributors": [
"tbrockman"
],
"scripts": {
"dev": "plasmo dev",
"build": "plasmo build",
"package": "plasmo package"
},
"dependencies": {
"bip39": "3.1.0",
"buffer": "6.0.3",
"events": "3.3.0",
"plasmo": "workspace:*",
"process": "0.11.10",
"stream-browserify": "3.0.0"
},
"devDependencies": {
"@ianvs/prettier-plugin-sort-imports": "4.1.1",
"@types/chrome": "0.0.258",
"@types/node": "20.11.5",
"@types/react": "18.2.48",
"@types/react-dom": "18.2.18",
"prettier": "3.2.4",
"typescript": "5.3.3"
},
"manifest": {
"host_permissions": [
"https://*/*"
],
"commands": {
"test": {
"suggested_key": {
"default": "Alt+W"
},
"description": "Print a console log"
}
},
"overrides": {
"chrome": {
"commands": {
"test": {
"suggested_key": {
"default": "Alt+W"
},
"description": "Print a console log"
},
"test-chrome": {
"suggested_key": {
"default": "Alt+X"
},
"description": "Print a console log specific to Chrome"
}
}
}
}
}
}
19 changes: 19 additions & 0 deletions with-browser-specific-overrides/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"extends": "plasmo/templates/tsconfig.base",
"exclude": [
"node_modules"
],
"include": [
".plasmo/index.d.ts",
"./**/*.ts",
"./**/*.tsx"
],
"compilerOptions": {
"paths": {
"~*": [
"./*"
]
},
"baseUrl": "."
}
}

0 comments on commit 62613fa

Please sign in to comment.