Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 30 additions & 13 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,54 +1,71 @@
.PHONY:
install clean install dev valid test prod all
tune2chrome tune2firefox
.DEFAULT_GOAL := dev

CHROME_ZIP = "extension.chrome.zip"
# Ensure environment dependencies exist
REQUIRED_BINS := deno jq zip tree
$(foreach bin,$(REQUIRED_BINS),$(if $(shell command -v $(bin) 2> /dev/null),,$(error Missing dependency: `$(bin)`)))

CHROME_MANIFEST = ./manifest.chrome.json
FIREFOX_ZIP = "extension.firefox.zip"
CHROME_MANIFEST_VERSION != jq -j '.version' $(CHROME_MANIFEST)
CHROME_ZIP = "extension.chrome-$(CHROME_MANIFEST_VERSION).zip"
FIREFOX_MANIFEST = ./manifest.firefox.json
DENO_DEV = NODE_ENV=development deno run --watch
DENO_PROD = NODE_ENV=production deno run
DENO_OPTIONS = --allow-env --allow-read --allow-run
FIREFOX_MANIFEST_VERSION != jq -j '.version' $(FIREFOX_MANIFEST)
FIREFOX_ZIP = "extension.firefox-$(FIREFOX_MANIFEST_VERSION).zip"
DENO_DEV = BUILD_MODE=development deno run --watch --allow-env --allow-read --allow-run
DENO_PROD = BUILD_MODE=production deno run --allow-env --allow-read --allow-run
OUTPUT_DIR = ./public/
BUILD_DIR = ./public/build/
BUILD_SCRIPT = ./build.ts

.PHONY: clean
clean:
rm -rf ./node_modules ./deno.lock $(BUILD_DIR) $(CHROME_ZIP) $(FIREFOX_ZIP)

.PHONY: install
install:
deno install --allow-scripts

.PHONY: update
update:
deno update --latest

.PHONY: dev
dev:
rm -rf $(BUILD_DIR)
$(DENO_DEV) $(DENO_OPTIONS) $(BUILD_SCRIPT)
$(DENO_DEV) $(BUILD_SCRIPT)

.PHONY: valid
valid:
deno fmt --unstable-component
deno lint
deno check

.PHONY: test
test: valid
deno test --no-check --trace-leaks --reporter=dot

.PHONY: prod
prod: test
rm -rf $(BUILD_DIR)
$(DENO_PROD) $(DENO_OPTIONS) $(BUILD_SCRIPT)
$(DENO_PROD) $(BUILD_SCRIPT)
deno audit

.PHONY: tune2chrome
tune2chrome:
cp $(CHROME_MANIFEST) manifest.json

.PHONY: tune2firefox
tune2firefox:
cp $(FIREFOX_MANIFEST) manifest.json

.PHONY: all
all: prod
make tune2firefox
$(MAKE) tune2firefox
rm -rf $(FIREFOX_ZIP)
zip -r $(FIREFOX_ZIP) $(OUTPUT_DIR) ./manifest.json > /dev/null

make tune2chrome
$(MAKE) tune2chrome
rm -rf $(CHROME_ZIP)
zip -r $(CHROME_ZIP) $(OUTPUT_DIR) ./manifest.json > /dev/null
zip --delete $(CHROME_ZIP) "$(BUILD_DIR)firefox/*" > /dev/null

tree -Dis $(BUILD_DIR) *.zip
tree -Dis $(BUILD_DIR) *.zip | grep -E "\\.css|\\.js|\\.zip"
14 changes: 8 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -147,16 +147,18 @@ declare global {
}
```

### Build requirements
- Linux: [deno](https://docs.deno.com/runtime/getting_started/installation/), `make`, `jq`, `zip`, `tree`

### Build instructions

- Linux
- [Deno](https://docs.deno.com/runtime/getting_started/installation/) 2.2.8
Here is a short list to help you get started, for a full set of make commands refer to [./Makefile](./Makefile):

```sh
make install # install dependencies
make all # build for prod and make extension.${browser}.zip
make tune2chrome # or tune2firefox for relevant manifest.json file
make dev # local development
make clean install # install dependencies
make tune2chrome # or tune2firefox to generate relevant manifest.json file
make dev # build in development mode and watch for changes
make all # build in production mode and make extension zip files
```

#### Based on
Expand Down
9 changes: 5 additions & 4 deletions build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@ import { build, type BuildOptions, context, stop } from 'esbuild';
import manifest from './manifest.json' with { type: 'json' };
import { vue3Plugin } from 'esbuild-plugin-vue-iii';

const nodeEnv = Deno.env.get('NODE_ENV');
const isProd = nodeEnv === 'production';
const isProd = Deno.env.get('BUILD_MODE') === 'production';
const buildMode = isProd ? 'production' : 'development';
const logLevel = isProd ? 'warning' : 'debug';
const buildOptions: BuildOptions = {
plugins: [
vue3Plugin({
Expand Down Expand Up @@ -35,11 +36,11 @@ const buildOptions: BuildOptions = {
platform: 'browser',
format: 'iife',
target: 'esnext',
conditions: [`${nodeEnv}`],
conditions: [buildMode],
minify: isProd,
sourcemap: false,
treeShaking: true,
logLevel: isProd ? 'warning' : 'debug',
logLevel,
};

if (isProd) {
Expand Down
7 changes: 4 additions & 3 deletions deno.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"lib": ["dom", "dom.iterable", "dom.asynciterable", "deno.ns"],
"strict": true
},
"exclude": ["tmp/"],
"lint": {
"include": [
"src/",
Expand Down Expand Up @@ -32,10 +33,10 @@
]
},
"imports": {
"esbuild": "https://deno.land/x/esbuild@v0.25.2/mod.js",
"esbuild": "npm:esbuild@0.27.3",
"esbuild-plugin-vue-iii": "npm:esbuild-plugin-vue-iii@0.5.0",

"@std/expect": "jsr:@std/expect@1.0.15",
"@std/testing": "jsr:@std/testing@1.0.11"
"@std/expect": "jsr:@std/expect@1.0.17",
"@std/testing": "jsr:@std/testing@1.0.17"
}
}
Loading
Loading