使用 create-react-app 快速创建浏览器插件。在 options page 和 popup page 中使用 react。
create-react-app my-extension --scripts-version browser-extension-react-scripts
// or create extension using typescript
create-react-app my-extension --typescript --scripts-version browser-extension-react-scripts
cd my-extension
npm start chrome
// or start develop Firefox plugin
npm start firefox
然后在浏览器插件页中加载在 dev 文件夹中未打包的插件。
当你想要发布时,使用 npm run build
创建一个打包后的插件。
通过 Webpack 打包后生成了编译过的问题。这里是一些相关插件商店发布规则。
Code Readability Requirements: Developers must not obfuscate code or conceal functionality of their extension. This also applies to any external code or resource fetched by the extension package. Minification is allowed, including the following forms:
Removal of whitespace, newlines, code comments, and block delimiters
Shortening of variable and function names
Collapsing files together
Add-ons may contain transpiled, minified or otherwise machine-generated code, but Mozilla needs to review a copy of the human-readable source code. The author must provide this information to Mozilla during submission along with instructions on how to reproduce the build.
The provided source code will be reviewed by an administrator and will not be redistributed in any way. The code will only be used for the purpose of reviewing the add-on. Failure to provide this information will result in rejection.
Add-ons are not allowed to contain obfuscated code, nor code that hides the purpose of the functionality involved. If external resources are used in combination with add-on code, the functionality of the code must not be obscured. To the contrary, minification of code with the intent to reduce file size is permitted.
Create React Browser Extension is open source software licensed as MIT.
这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。
V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。
V2EX is a community of developers, designers and creative people.