Coder Social home page Coder Social logo

extension-boilerplate's Introduction

Extension Boilerplate

This documentation is not yet complete, but the code is functional.

Installation

Clone the repo and install the required dependencies:

git clone --depth 1 --branch main https://github.com/ErrorGamer2000/extension-boilerplate.git your-project-name
cd your-project-name
npm install

Development

To start the development script, simply run

npm start

Extension Manifest

The extension's manifest is pre-populated with a basic configuration, although it is most likely nothing like what you will need in the project. The only thing that needs to remain the same is the tabs permission, which is used for the livereloading of the background service worker.

Adding Extension Pages

To add a web page to the extension, simply make a new directory in src/pages, and add an index file (js, ts, jsx, or tsx) and an index.html file with the following:

<html>
  <head>
    <%= htmlWebpackPlugin.tags.headTags %>
  </head>
  <body>
    <%= htmlWebpackPlugin.tags.bodyTags %>
    <!-- Your elements here -->
  </body>
</html>

Live Reload

This boilerplate supports live reload by default. All you have to do is import the correct file from the livereload folder. The background and popup scripts already have these imports, as well as the settings page. To add livereload to your page, simply add

import "../../livereload/page";

To the top of the script.

In order to reload the extension's service worker (because of MV3), the extension comes with, and will automatically open, a reload page, which connects to the livereload server and will send a message to the service worker, waking it up and reloading the extension. Closing this tab will disable livereload during development.

None of the livereload code will be added to the production code, thanks to the if-def webpack plugin, although the reload page will still be emitted.

The livereload server uses localhost port 5001 by default, but this can be canged in the config/port.json file;

Additional Content Scripts

By default, the boilerplate ships with the configuration for a single content script.

License

MIT © ErrorGamer2000

extension-boilerplate's People

Contributors

nexensys avatar

Stargazers

 avatar  avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.