From da9c7ee7a219ca55e200b8f193845b9838e17b44 Mon Sep 17 00:00:00 2001 From: Hamcha Date: Thu, 18 Jun 2020 14:07:10 +0200 Subject: [PATCH] Should fix sw issue, also always build versioned on master --- .drone.yml | 9 +++------ build.js | 4 +--- package.json | 1 + src/index.ts | 2 +- tsconfig.json | 6 +++++- yarn.lock | 5 +++++ 6 files changed, 16 insertions(+), 11 deletions(-) diff --git a/.drone.yml b/.drone.yml index 9ed0c4b..9a8d607 100644 --- a/.drone.yml +++ b/.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 diff --git a/build.js b/build.js index 57b10cf..7f4be77 100644 --- a/build.js +++ b/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, diff --git a/package.json b/package.json index 3f5da0a..a89522a 100644 --- a/package.json +++ b/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", diff --git a/src/index.ts b/src/index.ts index c888890..f2500ba 100644 --- a/src/index.ts +++ b/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) => { diff --git a/tsconfig.json b/tsconfig.json index bd4d686..70ae44c 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,5 +1,9 @@ { "compilerOptions": { - "target": "ES2020" + "target": "ES2020", + "baseUrl": ".", + "paths": { + "~*": ["./src/*"] + } } } diff --git a/yarn.lock b/yarn.lock index 5c87377..b0463ca 100644 --- a/yarn.lock +++ b/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"