chrome-extension-webpack-boilerplate

授权协议 MIT License
开发语言 JavaScript
所属分类 Web应用开发、 常用JavaScript包
软件类型 开源软件
地区 不详
投 递 者 方建明
操作系统 跨平台
开源组织
适用人群 未知
 软件概览

Chrome Extension Webpack Boilerplate

A basic foundation boilerplate for rich Chrome Extensions using Webpack to help you write modular and modern Javascript code, load CSS easily and automatic reload the browser on code changes.

Developing a new extension

I'll assume that you already read the Webpack docs and the Chrome Extension docs.

  1. Check if your Node.js version is >= 6.
  2. Clone the repository.
  3. Install yarn.
  4. Run yarn.
  5. Change the package's name and description on package.json.
  6. Change the name of your extension on src/manifest.json.
  7. Run yarn run start
  8. Load your extension on Chrome following:
    1. Access chrome://extensions/
    2. Check Developer mode
    3. Click on Load unpacked extension
    4. Select the build folder.
  9. Have fun.

Structure

All your extension's development code must be placed in src folder, including the extension manifest.

The boilerplate is already prepared to have a popup, a options page and a background page. You can easily customize this.

Each page has its own assets package defined. So, to code on popup you must start your code on src/js/popup.js, for example.

You must use the ES6 modules to a better code organization. The boilerplate is already prepared to that and here you have a little example.

Webpack auto-reload and HRM

To make your workflow much more efficient this boilerplate uses the webpack server to development (started with yarn run server) with auto reload feature that reloads the browser automatically every time that you save some file o your editor.

You can run the dev mode on other port if you want. Just specify the env var port like this:

$ PORT=6002 yarn run start

Content Scripts

Although this boilerplate uses the webpack dev server, it's also prepared to write all your bundles files on the disk at every code change, so you can point, on your extension manifest, to your bundles that you want to use as content scripts, but you need to exclude these entry points from hot reloading (why?). To do so you need to expose which entry points are content scripts on the webpack.config.js using the chromeExtensionBoilerplate -> notHotReload config. Look the example below.

Let's say that you want use the myContentScript entry point as content script, so on your webpack.config.js you will configure the entry point and exclude it from hot reloading, like this:

{
  
  entry: {
    myContentScript: "./src/js/myContentScript.js"
  },
  chromeExtensionBoilerplate: {
    notHotReload: ["myContentScript"]
  }
  
}

and on your src/manifest.json:

{
  "content_scripts": [
    {
      "matches": ["https://www.google.com/*"],
      "js": ["myContentScript.bundle.js"]
    }
  ]
}

Packing

After the development of your extension run the command

$ NODE_ENV=production yarn run build

Now, the content of build folder will be the extension ready to be submitted to the Chrome Web Store. Just take a look at the official guide to more infos about publishing.

Secrets

If you are developing an extension that talks with some API you probably are using different keys for testing and production. Is a good practice you not commit your secret keys and expose to anyone that have access to the repository.

To this task this boilerplate import the file ./secrets.<THE-NODE_ENV>.js on your modules through the module named as secrets, so you can do things like this:

./secrets.development.js

export default { key: "123" };

./src/popup.js

import secrets from "secrets";
ApiCall({ key: secrets.key });

�� The files with name secrets.*.js already are ignored on the repository.

With React.js

�� If you want use React.js with this boilerplate, check the react branch.

Contributing

  1. Please!! Do not create a pull request without an issue before discussing the problem.
  2. On your PR make sure that you are following the current codebase style.
  3. Your PR must be single purpose. Resolve just one problem on your PR.
  4. Make sure to commit in the same style that we are committing until now on the project.

Samuel Simões ~ @samuelsimoes ~ Blog

  • 前不久我写了一个 chrome 扩展,作为一个前端弄潮儿,我当然想用上各种前端界最 fashion 的开发工具。于是乎,折腾到最后使用了 webpack + TypeScript + react 这么一套技术栈。在 github 上研究了几个模板项目之后,发现大多数都太初级了,功能太简单,而且有一个我觉应当提供的很基础的功能始终没发现有哪个项目支持,也就是当修改了 content script 之

  • 此文粗略记录用 React+TypeScript+Firebase 实现一个用来统计 Gitlab Spent Time 的 Chrome Extension 的过程。 内容包括: 背景 功能介绍 如何使用 用 Webpack 配置多个 js 入口 使用 TypeScript 把它变成 Chrome extension 使用 Firebase Auth 实现注册登录 使用 Firestore 存取

  • 翻译:疯狂的技术宅 原文:www.sitepoint.com/build-vue-c… 未经允许严禁转载 浏览器扩展程序是可以修改和增强 Web 浏览器功能的小程序。它们可用于各种任务,例如阻止广告,管理密码,组织标签,改变网页的外观和行为等等。 好消息是浏览器扩展并不难写。可以用你已经熟悉的 Web 技术(HTML、CSS 和 JavaScript)创建 —— 就像普通网页一样。但是与网页不同的

  • m-fe/react-ts-webpack 在 Web 开发导论/微前端与大前端一文中,笔者简述了微服务与微前端的设计理念以及微前端的潜在可行方案。微服务与微前端,都是希望将某个单一的单体应用,转化为多个可以独立运行、独立开发、独立部署、独立维护的服务或者应用的聚合,从而满足业务快速变化及分布式多团队并行开发的需求。如康威定律(Conway’s Law)所言,设计系统的组织,其产生的设计和架构等价

  • 原文链接:github.com/lzwaiwai/bl… 最近写了一个可以利用 vue 或者 react 快速开发 chrome 插件的 boilerplate,只需要使用我之前写的 bigroom-cli 工具,就可快速简单地进行启动、打包、编译等,同时也支持保存代码后,插件自动更新,页面自动刷新。 boilerplate 生成: 首先我们安装 bigroom-cli: npm install

 相关资料
  • chrome-extension 是 Octo-Linker Chrome 扩展。 这款谷歌 Chrome 扩展允许您轻松地浏览 GitHub.com 上的文件和包。它非常支持JavaScript ,如package.json bower.json ES2015 import 和 CommonJS 声明,它也支持 PHP 的 composer.json 。其他语言不久也将被添加进这个扩展。 预览

  • 开源中国 (oschina.net) 谷歌浏览器插件,聚合开源中国每日最新资讯、推荐精品博客、最新收录开源软件等优质内容。 安装使用方式:通过 Chrome Web Store 下载 (注意打开方式) 安装使用方式:通过源码安装 git clone 本项目 打开 Chrome 浏览器 Extensions 页面 打开「Developer mode」 选择左上角「Load unpacked」之后选择

  • Angular Chrome Extension Scaffold Easily create Google Chrome Extensions (v3) using the latest version of Angular. The following scenarios/options are supported: Popup ✓ New Tab ✓ Options ✓ Service Wo

  • Chrome Extension CLI The CLI for your next Chrome Extension. �� Quick Overview npm install -g chrome-extension-clichrome-extension-cli my-extensioncd my-extensionnpm run watch Then follow these instru

  • awesome-chrome-extension-boilerplate 一个超棒的基于 React & TypeScript & webpack 的 chrome 扩展开发模板 ✨ 特性 �� 支持修改 content scripts 代码自动重载扩展和刷新注入了 content scripts的页面,再也不用修改了 content scripts 后手动刷新扩展和页面了。 �� options

  • vue-chrome-extension-boilerplate Boilerplate for Chrome extension using Vue.js and Webpack with auto-reload enabled. Scripts // install dependenciesnpm install// build extension and watch for changesn