Chrome Extension Development Basics with pebl: A Powerful Combination for Building and Deploying Extensions
Hatched by Kelvin
Sep 26, 2023
4 min read
7 views
Chrome Extension Development Basics with pebl: A Powerful Combination for Building and Deploying Extensions
Overview
In this article, we will explore the basics of Chrome extension development and how they can be enhanced using pebl, a complete and free cloud platform. By combining these two powerful tools, developers can create and deploy high-quality extensions with ease.
Hello Extensions
To begin, let's create a simple "Hello Extensions" example using Chrome extension development basics. Start by creating a new directory to store extension files. Then, create a manifest.json file and add the necessary code to describe the extension's capabilities and configuration. Additionally, create a hello.html file for the extension's popup.
Loading an Unpacked Extension
Once the extension is created, it can be loaded locally in Chrome. Enable Developer Mode in the Extensions page and click the Load unpacked button to select the extension directory. This will install the extension and display a generic icon for it.
Pinning the Extension
By default, the loaded extension will appear in the extensions menu. However, developers can pin the extension to the toolbar for quick access during development. Simply click on the extension's action icon to see a popup.
Reloading the Extension
To make changes to the extension, modify the manifest.json file and refresh the extension in the browser. This can be done by going to the Extensions page and clicking the refresh icon. It's important to note that changes made to the extension require a refresh to take effect.
Finding Console Logs and Errors
During development, it's helpful to locate console logs and errors for debugging purposes. By adding a script tag to the hello.html file and creating a popup.js file, developers can access and view console logs in the browser's DevTools.
Structuring an Extension Project
There are various ways to structure an extension project, but it's important to place the manifest.json file in the extension's root directory. This ensures that the extension functions properly and follows best practices for organization.
Using TypeScript
If developers are using a code editor like VSCode or Atom, they can take advantage of the chrome-types npm package for auto-completion of the Chrome API. This package is automatically updated with changes to the Chromium source code, so it's important to frequently update it to work with the latest version.
Microservices with pebl
In addition to Chrome extension development, developers can leverage pebl, a complete and free cloud platform, to enhance the functionality and deployment of their extensions. Unlike traditional Infrastructure as Code approaches, pebl integrates cloud capabilities within the application through language-specific SDKs.
Signing Up and Docker & pebl CLI
To get started with pebl, developers need to sign up for a free account at pebl.io and ensure they have Docker and the pebl CLI installed. Docker is necessary for containerization, while the pebl CLI provides the necessary commands for deploying and managing pebl projects.
Simple Service with pebl
The core building block in pebl is a service, which is similar to a serverless application. Developers can create a simple service using Python by following the provided code example. This service can respond to requests and is integrated with pebl's capabilities.
Local Runtime and Cloud Runtime
Pebl allows developers to execute their code locally to ensure correctness and provide a fast iteration cycle. By starting a local cluster with pebl up and running the service with pebl run, developers can test and debug their code before deploying it to the cloud.
Internal Services and Redis
Pebl also supports internal services, which are only exposed to other workloads within the cluster. Developers can utilize internal services to break their cloud workloads into smaller, more manageable components. Additionally, pebl provides persistence through Redis, which can be easily incorporated into applications using the pebl SDK.
Proxying and Deploying
To utilize internal services, developers can proxy requests from external services to internal ones. This can be done by updating the main.py file and incorporating the requests library. Once the changes are made, developers can deploy their services using the pebl deploy command.
Redis Management
To access Redis in the cloud runtime, developers can utilize the pebl tunnel command to establish a tunnel and connect to the Redis instance. This allows for easy management of data and ensures consistency between local and cloud runtimes.
Next Steps
By combining Chrome extension development basics with pebl, developers have a powerful set of tools for building and deploying extensions. It's important to explore the SDK reference and guides provided by pebl to fully leverage its capabilities and enhance extension development.
Actionable Advice:
- Regularly refresh and test your Chrome extension during development to ensure that changes take effect and the extension functions as expected.
- Utilize the pebl CLI to deploy and manage your extensions in the cloud runtime, allowing for easy scalability and accessibility.
- Explore the capabilities of pebl, such as internal services and Redis, to enhance the functionality and performance of your extensions.
In conclusion, combining Chrome extension development basics with pebl opens up a world of possibilities for developers. By leveraging the power of Chrome extensions and the capabilities of pebl, developers can create and deploy high-quality extensions with ease and efficiency.
Sources
Hatch New Ideas with Glasp AI 🐣
Glasp AI allows you to hatch new ideas based on your curated content. Let's curate and create with Glasp AI :)
Start Hatching 🐣