Browse Source

Should fix sw issue, also always build versioned on master

dev
Hamcha 1 year ago
parent
commit
da9c7ee7a2
Signed by untrusted user: Hamcha GPG Key ID: 41467804B19A3315
  1. 9
      .drone.yml
  2. 4
      build.js
  3. 1
      package.json
  4. 2
      src/index.ts
  5. 6
      tsconfig.json
  6. 5
      yarn.lock

9
.drone.yml

@ -33,7 +33,7 @@ steps:
commands:
- yarn build
environment:
SUBPATH: /${DRONE_COMMIT_SHA:0:8}
SUBPATH: /tghandbook/${DRONE_COMMIT_BRANCH/\//_}-${DRONE_COMMIT_SHA:0:8}/dist
when:
event:
- push
@ -48,7 +48,7 @@ steps:
commands:
- yarn build
environment:
SUBPATH: /pr-${DRONE_PULL_REQUEST}
SUBPATH: /tghandbook/pr-${DRONE_PULL_REQUEST}/dist
when:
event:
- pull_request
@ -60,7 +60,7 @@ steps:
commands:
- yarn build
environment:
SUBPATH: /latest
SUBPATH: /tghandbook/latest/dist
when:
event:
- push
@ -84,9 +84,6 @@ steps:
when:
event:
- push
branch:
exclude:
- master
depends_on:
- build_versioned

4
build.js

@ -8,9 +8,7 @@ const entryFiles = Path.join(__dirname, "./index.html");
const options = {
outDir: "./dist",
outFile: "index.html",
publicUrl: process.env.SUBPATH
? "/tghandbook" + process.env.SUBPATH + "/dist"
: "/",
publicUrl: process.env.SUBPATH || "/",
watch: false,
contentHash: false,
scopeHoist: false,

1
package.json

@ -9,6 +9,7 @@
"build": "node ./build.js"
},
"dependencies": {
"@types/node": "^14.0.13",
"@types/service_worker_api": "^0.0.9",
"@typescript-eslint/eslint-plugin": "^3.3.0",
"@typescript-eslint/parser": "^3.3.0",

2
src/index.ts

@ -14,7 +14,7 @@ defaultTabs.forEach((tab) => {
});
if ("serviceWorker" in navigator) {
const x = "sw.js";
const x = process.env.SUBPATH ? `${process.env.SUBPATH}/sw.js` : "sw.js";
navigator.serviceWorker
.register(x)
.then((registration) => {

6
tsconfig.json

@ -1,5 +1,9 @@
{
"compilerOptions": {
"target": "ES2020"
"target": "ES2020",
"baseUrl": ".",
"paths": {
"~*": ["./src/*"]
}
}
}

5
yarn.lock

@ -949,6 +949,11 @@
resolved "https://registry.yarnpkg.com/@types/json5/-/json5-0.0.29.tgz#ee28707ae94e11d2b827bcbe5270bcea7f3e71ee"
integrity sha1-7ihweulOEdK4J7y+UnC86n8+ce4=
"@types/node@^14.0.13":
version "14.0.13"
resolved "https://registry.yarnpkg.com/@types/node/-/node-14.0.13.tgz#ee1128e881b874c371374c1f72201893616417c9"
integrity sha512-rouEWBImiRaSJsVA+ITTFM6ZxibuAlTuNOCyxVbwreu6k6+ujs7DfnU9o+PShFhET78pMBl3eH+AGSI5eOTkPA==
"@types/q@^1.5.1":
version "1.5.4"
resolved "https://registry.yarnpkg.com/@types/q/-/q-1.5.4.tgz#15925414e0ad2cd765bfef58842f7e26a7accb24"

Loading…
Cancel
Save