Skip to content

Commit e93e7db

Browse files
authored
refactor: move to using bundle-text imports and reduce minification (#297)
1 parent c397ab5 commit e93e7db

File tree

4 files changed

+81
-36
lines changed

4 files changed

+81
-36
lines changed

package.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,16 @@
44
"description": "Provides more features to the Hoppscotch webapp (https://hoppscotch.io/)",
55
"scripts": {
66
"clean": "rimraf dist .parcel-cache",
7-
"build:chrome": "HOPP_EXTENSION_TARGET=CHROME parcel build src/* --dist-dir dist/ && copyfiles icons/* dist",
8-
"build:firefox": "HOPP_EXTENSION_TARGET=FIREFOX parcel build src/* --dist-dir dist/ && copyfiles icons/* dist"
7+
"build:chrome": "HOPP_EXTENSION_TARGET=CHROME parcel build src/* --dist-dir dist/ --no-optimize && copyfiles icons/* dist",
8+
"build:firefox": "HOPP_EXTENSION_TARGET=FIREFOX parcel build src/* --dist-dir dist/ --no-optimize && copyfiles icons/* dist"
99
},
1010
"author": "Andrew Bastin",
1111
"license": "MIT",
1212
"devDependencies": {
1313
"@parcel/config-default": "^2.10.0",
1414
"@parcel/core": "^2.10.0",
1515
"@parcel/plugin": "^2.10.0",
16+
"@parcel/transformer-inline-string": "2.10.0",
1617
"@parcel/transformer-raw": "^2.10.0",
1718
"@types/chrome": "^0.0.246",
1819
"@types/node": "^17.0.23",
@@ -25,6 +26,7 @@
2526
},
2627
"dependencies": {
2728
"axios": "^1.5.1",
29+
"lit": "^3.1.3",
2830
"lit-html": "^3.0.0"
2931
}
3032
}

pnpm-lock.yaml

Lines changed: 71 additions & 17 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/contentScript.ts

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,12 @@
1-
const fs = require("fs")
1+
import hookContent from "bundle-text:./hookContent.js"
2+
import hookContentInvalidOrigin from "bundle-text:./hookContentInvalidOrigin.js"
23

34
declare global {
45
interface Window {
56
HOPP_CONTENT_SCRIPT_EXECUTED: boolean
67
}
78
}
89

9-
const hookContent = fs.readFileSync(__dirname + "/hookContent.js", {
10-
encoding: "utf-8",
11-
})
12-
13-
const hookContentInvalidOrigin = fs.readFileSync(
14-
__dirname + "/hookContentInvalidOrigin.js",
15-
{
16-
encoding: "utf-8",
17-
}
18-
)
19-
2010
export type HOOK_MESSAGE = {
2111
type: "execute_hook"
2212
origin_type: "VALID_ORIGIN" | "UNKNOWN_ORIGIN"

src/popup-script.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
11
import { html, render } from "lit-html"
2-
import { unsafeSVG } from "lit-html/directives/unsafe-svg"
2+
import { unsafeSVG } from "lit/directives/unsafe-svg"
3+
import ICON_ADD from "bundle-text:./add-icon.svg"
4+
import ICON_DELETE from "bundle-text:./delete-icon.svg"
5+
import ICON_ERROR from "bundle-text:./error-icon.svg"
36

47
import { DEFAULT_ORIGIN_LIST } from "./defaultOrigins"
58

69
const fs = require("fs")
710

8-
const ICON_ADD = fs.readFileSync(__dirname + "/add-icon.svg", "utf8")
9-
const ICON_DELETE = fs.readFileSync(__dirname + "/delete-icon.svg", "utf8")
10-
const ICON_ERROR = fs.readFileSync(__dirname + "/error-icon.svg", "utf8")
11-
1211
let origins: string[] = []
1312

1413
let inputText = ""

0 commit comments

Comments
 (0)