/gleam-browser-extension

A template for Gleam browser extensions.

Primary LanguageJavaScript

Gleam Browser Extension

A template for Gleam browser extensions.

Quick Overview

This project uses Lustre and Lustre Ui for simplicity.
Webpack is also used here, and WebpackObfuscator is added as an example.

πŸ”‹ Getting Started

You don’t need to configure Webpack.
Webpack comes in preconfigured, so that you can focus on the code.

Just clone this repo, run npm i and you’re good to go.

πŸ—ƒοΈ Project Structure

Current project structure:

gleam-browser-extension
β”œβ”€β”€ README.md
β”œβ”€β”€ build
β”œβ”€β”€ release
β”œβ”€β”€ node_modules
β”œβ”€β”€ index.html
β”œβ”€β”€ gleam.toml
β”œβ”€β”€ manifest.toml
β”œβ”€β”€ manifest.json
β”œβ”€β”€ package.json
β”œβ”€β”€ pack.mjs
β”œβ”€β”€ pack.toml
β”œβ”€β”€ .gitignore
β”œβ”€β”€ config                    // Webpack with minimal configurations.
β”‚   β”œβ”€β”€ paths.mjs
β”‚   β”œβ”€β”€ webpack.common.mjs
β”‚   └── webpack.config.mjs
β”œβ”€β”€ priv/static
β”‚   β”œβ”€β”€ icons
β”‚   β”‚   β”œβ”€β”€ icon_16.png
β”‚   β”‚   β”œβ”€β”€ icon_32.png
β”‚   β”‚   β”œβ”€β”€ icon_48.png
β”‚   β”‚   └── icon_128.png
β”‚   └── app.mjs               // Compiled app.
β”œβ”€β”€ test 
β”‚   └── *.gleam               // Gleam test files.
└── src
    └── *.gleam               // Gleam source files.

πŸ“ Usage

You can run some built-in commands:

npm run watch

Runs the app in development mode.
Then follow these instructions to see your app:

  1. Open chrome://extensions
  2. Check the Developer mode checkbox
  3. Click on the Load unpacked extension button
  4. Select the project folder

Or just open localhost:1234.

npm run build

Builds the app for production.
Run npm run pack to copy just the extension files into the release folder.

npm run pack

Packs extension files into the release folder.

npm run repack

Rebuilds and packs the app.
It is a shorthand for npm run build && npm run pack.

Contribution

Suggestions and pull requests are welcomed!


Many thanks to Chrome Extension CLI for the inspiration with this readme file.