From 69b5363c88265f5cae0e83e5a7b123875db65626 Mon Sep 17 00:00:00 2001 From: Jonas Pfalzgraf Date: Mon, 23 Jan 2023 14:44:47 +0100 Subject: [PATCH 1/3] Feature/webpack integration (#9) * working webpack into template * removing package-lock.json * implementing source --- .gitignore | 4 +- package-lock.json | 418 ---------------------------------- package.json | 18 +- src/app.ts | 4 +- src/settings.ts | 4 +- tooling.tsconfig.json | 28 +++ tools/clean.ts | 9 + tsconfig.json | 140 ++++++------ webpack.config.background.cjs | 28 +++ webpack.config.cjs | 28 +++ webpack.config.settings.cjs | 28 +++ 11 files changed, 208 insertions(+), 501 deletions(-) delete mode 100644 package-lock.json create mode 100644 tooling.tsconfig.json create mode 100644 tools/clean.ts create mode 100644 webpack.config.background.cjs create mode 100644 webpack.config.cjs create mode 100644 webpack.config.settings.cjs diff --git a/.gitignore b/.gitignore index e0400f6..786253e 100644 --- a/.gitignore +++ b/.gitignore @@ -689,4 +689,6 @@ dist tools/syncConfig.js tools/deploy.js -tools/v2.js \ No newline at end of file +tools/v2.js +tools/clean.js +package-lock.json diff --git a/package-lock.json b/package-lock.json deleted file mode 100644 index 7fdbd2b..0000000 --- a/package-lock.json +++ /dev/null @@ -1,418 +0,0 @@ -{ - "name": "browser_extension_template", - "version": "0.0.1", - "lockfileVersion": 2, - "requires": true, - "packages": { - "": { - "name": "browser_extension_template", - "version": "0.0.1", - "license": "MIT", - "devDependencies": { - "@types/node": "^18.7.4", - "sass": "^1.39.0", - "typescript": "^4.2.4" - } - }, - "node_modules/@types/node": { - "version": "18.7.4", - "resolved": "https://registry.npmjs.org/@types/node/-/node-18.7.4.tgz", - "integrity": "sha512-RzRcw8c0B8LzryWOR4Wj7YOTFXvdYKwvrb6xQQyuDfnlTxwYXGCV5RZ/TEbq5L5kn+w3rliHAUyRcG1RtbmTFg==", - "dev": true - }, - "node_modules/anymatch": { - "version": "3.1.2", - "resolved": "https://registry.npmjs.org/anymatch/-/anymatch-3.1.2.tgz", - "integrity": "sha512-P43ePfOAIupkguHUycrc4qJ9kz8ZiuOUijaETwX7THt0Y/GNK7v0aa8rY816xWjZ7rJdA5XdMcpVFTKMq+RvWg==", - "dev": true, - "dependencies": { - "normalize-path": "^3.0.0", - "picomatch": "^2.0.4" - }, - "engines": { - "node": ">= 8" - } - }, - "node_modules/binary-extensions": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/binary-extensions/-/binary-extensions-2.2.0.tgz", - "integrity": "sha512-jDctJ/IVQbZoJykoeHbhXpOlNBqGNcwXJKJog42E5HDPUwQTSdjCHdihjj0DlnheQ7blbT6dHOafNAiS8ooQKA==", - "dev": true, - "engines": { - "node": ">=8" - } - }, - "node_modules/braces": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/braces/-/braces-3.0.2.tgz", - "integrity": "sha512-b8um+L1RzM3WDSzvhm6gIz1yfTbBt6YTlcEKAvsmqCZZFw46z626lVj9j1yEPW33H5H+lBQpZMP1k8l+78Ha0A==", - "dev": true, - "dependencies": { - "fill-range": "^7.0.1" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/chokidar": { - "version": "3.5.3", - "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-3.5.3.tgz", - "integrity": "sha512-Dr3sfKRP6oTcjf2JmUmFJfeVMvXBdegxB0iVQ5eb2V10uFJUCAS8OByZdVAyVb8xXNz3GjjTgj9kLWsZTqE6kw==", - "dev": true, - "funding": [ - { - "type": "individual", - "url": "https://paulmillr.com/funding/" - } - ], - "dependencies": { - "anymatch": "~3.1.2", - "braces": "~3.0.2", - "glob-parent": "~5.1.2", - "is-binary-path": "~2.1.0", - "is-glob": "~4.0.1", - "normalize-path": "~3.0.0", - "readdirp": "~3.6.0" - }, - "engines": { - "node": ">= 8.10.0" - }, - "optionalDependencies": { - "fsevents": "~2.3.2" - } - }, - "node_modules/fill-range": { - "version": "7.0.1", - "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.0.1.tgz", - "integrity": "sha512-qOo9F+dMUmC2Lcb4BbVvnKJxTPjCm+RRpe4gDuGrzkL7mEVl/djYSu2OdQ2Pa302N4oqkSg9ir6jaLWJ2USVpQ==", - "dev": true, - "dependencies": { - "to-regex-range": "^5.0.1" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/fsevents": { - "version": "2.3.2", - "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.2.tgz", - "integrity": "sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA==", - "dev": true, - "hasInstallScript": true, - "optional": true, - "os": [ - "darwin" - ], - "engines": { - "node": "^8.16.0 || ^10.6.0 || >=11.0.0" - } - }, - "node_modules/glob-parent": { - "version": "5.1.2", - "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-5.1.2.tgz", - "integrity": "sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow==", - "dev": true, - "dependencies": { - "is-glob": "^4.0.1" - }, - "engines": { - "node": ">= 6" - } - }, - "node_modules/immutable": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/immutable/-/immutable-4.1.0.tgz", - "integrity": "sha512-oNkuqVTA8jqG1Q6c+UglTOD1xhC1BtjKI7XkCXRkZHrN5m18/XsnUp8Q89GkQO/z+0WjonSvl0FLhDYftp46nQ==", - "dev": true - }, - "node_modules/is-binary-path": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/is-binary-path/-/is-binary-path-2.1.0.tgz", - "integrity": "sha512-ZMERYes6pDydyuGidse7OsHxtbI7WVeUEozgR/g7rd0xUimYNlvZRE/K2MgZTjWy725IfelLeVcEM97mmtRGXw==", - "dev": true, - "dependencies": { - "binary-extensions": "^2.0.0" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/is-extglob": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/is-extglob/-/is-extglob-2.1.1.tgz", - "integrity": "sha512-SbKbANkN603Vi4jEZv49LeVJMn4yGwsbzZworEoyEiutsN3nJYdbO36zfhGJ6QEDpOZIFkDtnq5JRxmvl3jsoQ==", - "dev": true, - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/is-glob": { - "version": "4.0.3", - "resolved": "https://registry.npmjs.org/is-glob/-/is-glob-4.0.3.tgz", - "integrity": "sha512-xelSayHH36ZgE7ZWhli7pW34hNbNl8Ojv5KVmkJD4hBdD3th8Tfk9vYasLM+mXWOZhFkgZfxhLSnrwRr4elSSg==", - "dev": true, - "dependencies": { - "is-extglob": "^2.1.1" - }, - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/is-number": { - "version": "7.0.0", - "resolved": "https://registry.npmjs.org/is-number/-/is-number-7.0.0.tgz", - "integrity": "sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==", - "dev": true, - "engines": { - "node": ">=0.12.0" - } - }, - "node_modules/normalize-path": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/normalize-path/-/normalize-path-3.0.0.tgz", - "integrity": "sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA==", - "dev": true, - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/picomatch": { - "version": "2.3.1", - "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.1.tgz", - "integrity": "sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==", - "dev": true, - "engines": { - "node": ">=8.6" - }, - "funding": { - "url": "https://github.com/sponsors/jonschlinkert" - } - }, - "node_modules/readdirp": { - "version": "3.6.0", - "resolved": "https://registry.npmjs.org/readdirp/-/readdirp-3.6.0.tgz", - "integrity": "sha512-hOS089on8RduqdbhvQ5Z37A0ESjsqz6qnRcffsMU3495FuTdqSm+7bhJ29JvIOsBDEEnan5DPu9t3To9VRlMzA==", - "dev": true, - "dependencies": { - "picomatch": "^2.2.1" - }, - "engines": { - "node": ">=8.10.0" - } - }, - "node_modules/sass": { - "version": "1.54.4", - "resolved": "https://registry.npmjs.org/sass/-/sass-1.54.4.tgz", - "integrity": "sha512-3tmF16yvnBwtlPrNBHw/H907j8MlOX8aTBnlNX1yrKx24RKcJGPyLhFUwkoKBKesR3unP93/2z14Ll8NicwQUA==", - "dev": true, - "dependencies": { - "chokidar": ">=3.0.0 <4.0.0", - "immutable": "^4.0.0", - "source-map-js": ">=0.6.2 <2.0.0" - }, - "bin": { - "sass": "sass.js" - }, - "engines": { - "node": ">=12.0.0" - } - }, - "node_modules/source-map-js": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/source-map-js/-/source-map-js-1.0.2.tgz", - "integrity": "sha512-R0XvVJ9WusLiqTCEiGCmICCMplcCkIwwR11mOSD9CR5u+IXYdiseeEuXCVAjS54zqwkLcPNnmU4OeJ6tUrWhDw==", - "dev": true, - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/to-regex-range": { - "version": "5.0.1", - "resolved": "https://registry.npmjs.org/to-regex-range/-/to-regex-range-5.0.1.tgz", - "integrity": "sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ==", - "dev": true, - "dependencies": { - "is-number": "^7.0.0" - }, - "engines": { - "node": ">=8.0" - } - }, - "node_modules/typescript": { - "version": "4.7.4", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.7.4.tgz", - "integrity": "sha512-C0WQT0gezHuw6AdY1M2jxUO83Rjf0HP7Sk1DtXj6j1EwkQNZrHAg2XPWlq62oqEhYvONq5pkC2Y9oPljWToLmQ==", - "dev": true, - "bin": { - "tsc": "bin/tsc", - "tsserver": "bin/tsserver" - }, - "engines": { - "node": ">=4.2.0" - } - } - }, - "dependencies": { - "@types/node": { - "version": "18.7.4", - "resolved": "https://registry.npmjs.org/@types/node/-/node-18.7.4.tgz", - "integrity": "sha512-RzRcw8c0B8LzryWOR4Wj7YOTFXvdYKwvrb6xQQyuDfnlTxwYXGCV5RZ/TEbq5L5kn+w3rliHAUyRcG1RtbmTFg==", - "dev": true - }, - "anymatch": { - "version": "3.1.2", - "resolved": "https://registry.npmjs.org/anymatch/-/anymatch-3.1.2.tgz", - "integrity": "sha512-P43ePfOAIupkguHUycrc4qJ9kz8ZiuOUijaETwX7THt0Y/GNK7v0aa8rY816xWjZ7rJdA5XdMcpVFTKMq+RvWg==", - "dev": true, - "requires": { - "normalize-path": "^3.0.0", - "picomatch": "^2.0.4" - } - }, - "binary-extensions": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/binary-extensions/-/binary-extensions-2.2.0.tgz", - "integrity": "sha512-jDctJ/IVQbZoJykoeHbhXpOlNBqGNcwXJKJog42E5HDPUwQTSdjCHdihjj0DlnheQ7blbT6dHOafNAiS8ooQKA==", - "dev": true - }, - "braces": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/braces/-/braces-3.0.2.tgz", - "integrity": "sha512-b8um+L1RzM3WDSzvhm6gIz1yfTbBt6YTlcEKAvsmqCZZFw46z626lVj9j1yEPW33H5H+lBQpZMP1k8l+78Ha0A==", - "dev": true, - "requires": { - "fill-range": "^7.0.1" - } - }, - "chokidar": { - "version": "3.5.3", - "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-3.5.3.tgz", - "integrity": "sha512-Dr3sfKRP6oTcjf2JmUmFJfeVMvXBdegxB0iVQ5eb2V10uFJUCAS8OByZdVAyVb8xXNz3GjjTgj9kLWsZTqE6kw==", - "dev": true, - "requires": { - "anymatch": "~3.1.2", - "braces": "~3.0.2", - "fsevents": "~2.3.2", - "glob-parent": "~5.1.2", - "is-binary-path": "~2.1.0", - "is-glob": "~4.0.1", - "normalize-path": "~3.0.0", - "readdirp": "~3.6.0" - } - }, - "fill-range": { - "version": "7.0.1", - "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.0.1.tgz", - "integrity": "sha512-qOo9F+dMUmC2Lcb4BbVvnKJxTPjCm+RRpe4gDuGrzkL7mEVl/djYSu2OdQ2Pa302N4oqkSg9ir6jaLWJ2USVpQ==", - "dev": true, - "requires": { - "to-regex-range": "^5.0.1" - } - }, - "fsevents": { - "version": "2.3.2", - "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.2.tgz", - "integrity": "sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA==", - "dev": true, - "optional": true - }, - "glob-parent": { - "version": "5.1.2", - "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-5.1.2.tgz", - "integrity": "sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow==", - "dev": true, - "requires": { - "is-glob": "^4.0.1" - } - }, - "immutable": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/immutable/-/immutable-4.1.0.tgz", - "integrity": "sha512-oNkuqVTA8jqG1Q6c+UglTOD1xhC1BtjKI7XkCXRkZHrN5m18/XsnUp8Q89GkQO/z+0WjonSvl0FLhDYftp46nQ==", - "dev": true - }, - "is-binary-path": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/is-binary-path/-/is-binary-path-2.1.0.tgz", - "integrity": "sha512-ZMERYes6pDydyuGidse7OsHxtbI7WVeUEozgR/g7rd0xUimYNlvZRE/K2MgZTjWy725IfelLeVcEM97mmtRGXw==", - "dev": true, - "requires": { - "binary-extensions": "^2.0.0" - } - }, - "is-extglob": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/is-extglob/-/is-extglob-2.1.1.tgz", - "integrity": "sha512-SbKbANkN603Vi4jEZv49LeVJMn4yGwsbzZworEoyEiutsN3nJYdbO36zfhGJ6QEDpOZIFkDtnq5JRxmvl3jsoQ==", - "dev": true - }, - "is-glob": { - "version": "4.0.3", - "resolved": "https://registry.npmjs.org/is-glob/-/is-glob-4.0.3.tgz", - "integrity": "sha512-xelSayHH36ZgE7ZWhli7pW34hNbNl8Ojv5KVmkJD4hBdD3th8Tfk9vYasLM+mXWOZhFkgZfxhLSnrwRr4elSSg==", - "dev": true, - "requires": { - "is-extglob": "^2.1.1" - } - }, - "is-number": { - "version": "7.0.0", - "resolved": "https://registry.npmjs.org/is-number/-/is-number-7.0.0.tgz", - "integrity": "sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==", - "dev": true - }, - "normalize-path": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/normalize-path/-/normalize-path-3.0.0.tgz", - "integrity": "sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA==", - "dev": true - }, - "picomatch": { - "version": "2.3.1", - "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.1.tgz", - "integrity": "sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==", - "dev": true - }, - "readdirp": { - "version": "3.6.0", - "resolved": "https://registry.npmjs.org/readdirp/-/readdirp-3.6.0.tgz", - "integrity": "sha512-hOS089on8RduqdbhvQ5Z37A0ESjsqz6qnRcffsMU3495FuTdqSm+7bhJ29JvIOsBDEEnan5DPu9t3To9VRlMzA==", - "dev": true, - "requires": { - "picomatch": "^2.2.1" - } - }, - "sass": { - "version": "1.54.4", - "resolved": "https://registry.npmjs.org/sass/-/sass-1.54.4.tgz", - "integrity": "sha512-3tmF16yvnBwtlPrNBHw/H907j8MlOX8aTBnlNX1yrKx24RKcJGPyLhFUwkoKBKesR3unP93/2z14Ll8NicwQUA==", - "dev": true, - "requires": { - "chokidar": ">=3.0.0 <4.0.0", - "immutable": "^4.0.0", - "source-map-js": ">=0.6.2 <2.0.0" - } - }, - "source-map-js": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/source-map-js/-/source-map-js-1.0.2.tgz", - "integrity": "sha512-R0XvVJ9WusLiqTCEiGCmICCMplcCkIwwR11mOSD9CR5u+IXYdiseeEuXCVAjS54zqwkLcPNnmU4OeJ6tUrWhDw==", - "dev": true - }, - "to-regex-range": { - "version": "5.0.1", - "resolved": "https://registry.npmjs.org/to-regex-range/-/to-regex-range-5.0.1.tgz", - "integrity": "sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ==", - "dev": true, - "requires": { - "is-number": "^7.0.0" - } - }, - "typescript": { - "version": "4.7.4", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.7.4.tgz", - "integrity": "sha512-C0WQT0gezHuw6AdY1M2jxUO83Rjf0HP7Sk1DtXj6j1EwkQNZrHAg2XPWlq62oqEhYvONq5pkC2Y9oPljWToLmQ==", - "dev": true - } - } -} diff --git a/package.json b/package.json index 67ccc8c..3bd50a2 100644 --- a/package.json +++ b/package.json @@ -4,19 +4,24 @@ "private": true, "type": "module", "scripts": { - "deploy-v3": "npm run build-tooling && npm run sync && node ./tools/deploy.js && npm run build-js && npm run build-css", + "deploy-v3": "npm run build-tooling && node ./tools/deploy.js && npm run sync && npm run build-js && npm run build-css && node ./tools/clean.js", "deploy-v2": "npm run deploy-v3 && node ./tools/v2.js", - "build-js": "tsc -p tsconfig.json", + "build-js": "webpack --config ./webpack.config.cjs && webpack --config ./webpack.config.settings.cjs && webpack --config ./webpack.config.background.cjs", "build-css": "sass ./src/sass/:./dist/css/", - "build-tooling": "tsc ./tools/v2.ts --target esnext --module esnext --lib ESNext && tsc ./tools/syncConfig.ts --target esnext --module esnext --lib ESNext && tsc ./tools/deploy.ts --target esnext --module esnext --lib ESNext", + "build-tooling": "tsc --project ./tooling.tsconfig.json", "watch-ts": "tsc -w -p tsconfig.json", "watch-sass": "sass --watch ./src/sass/:./dist/css/", "sync": "npm run build-tooling && node ./tools/syncConfig.js" }, "devDependencies": { - "@types/node": "^18.7.4", + "@types/chrome": "^0.0.206", + "@types/node": "^18.11.18", + "@webcomponents/webcomponentsjs": "^2.7.0", "sass": "^1.39.0", - "typescript": "^4.2.4" + "typescript": "^4.2.4", + "ts-loader": "^9.4.2", + "webpack": "^5.75.0", + "webpack-cli": "^5.0.1" }, "browserslist": [ "> 1%", @@ -38,5 +43,8 @@ }, "bugs": { "url": "https://github.com/JosunLP/BrowserExtensionTemplate/issues" + }, + "dependencies": { + "@webcomponents/custom-elements": "^1.5.1" } } \ No newline at end of file diff --git a/src/app.ts b/src/app.ts index 727e9f0..3dc1fa6 100644 --- a/src/app.ts +++ b/src/app.ts @@ -1,4 +1,4 @@ -import { Session } from "./classes/session.js" +import { Session } from "./classes/session" class App { @@ -27,4 +27,4 @@ class App { } } -new App(); \ No newline at end of file +new App(); diff --git a/src/settings.ts b/src/settings.ts index 8e0af66..60538bd 100644 --- a/src/settings.ts +++ b/src/settings.ts @@ -1,5 +1,5 @@ -import { Session } from "./classes/session.js"; -import { BasicButton } from "./components/button.js"; +import { Session } from "./classes/session"; +import { BasicButton } from "./components/button"; class Settings { diff --git a/tooling.tsconfig.json b/tooling.tsconfig.json new file mode 100644 index 0000000..84ac8bc --- /dev/null +++ b/tooling.tsconfig.json @@ -0,0 +1,28 @@ +{ + "compilerOptions": { + "target": "ESNext", + "module": "ESNext", + "outDir": "./tools/", + "rootDir": "./tools/", + "removeComments": true, + "moduleResolution": "node", + "strict": true, + "esModuleInterop": true, + "skipLibCheck": true, + "forceConsistentCasingInFileNames": true, + "types": [ + "node", + "chrome" + ] + }, + "include": [ + "./tools/*.ts" + ], + "exclude": [ + "node_modules", + "./src/*.ts", + "./src/**/*.ts", + "./dist/*.ts", + "./dist/*.js" + ] +} diff --git a/tools/clean.ts b/tools/clean.ts new file mode 100644 index 0000000..caba573 --- /dev/null +++ b/tools/clean.ts @@ -0,0 +1,9 @@ +import * as fs from "fs"; + +function removeExport(file: string) { + let content = fs.readFileSync(file, "utf8"); + content = content.replace("export {};", ""); + fs.writeFileSync(file, content); +} + +removeExport("./dist/js/background.js"); diff --git a/tsconfig.json b/tsconfig.json index fe9081d..3e8038b 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,81 +1,75 @@ { - "compilerOptions": { - /* Visit https://aka.ms/tsconfig.json to read more about this file */ + "compilerOptions": { + /* Visit https://aka.ms/tsconfig.json to read more about this file */ - /* Basic Options */ - // "incremental": true, /* Enable incremental compilation */ - "target": "ESNext", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019', 'ES2020', 'ES2021', or 'ESNEXT'. */ - "module": "ESNext", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', 'es2020', or 'ESNext'. */ - // "lib": ["ESNext"], /* Specify library files to be included in the compilation. */ - // "allowJs": true, /* Allow javascript files to be compiled. */ - // "checkJs": true, /* Report errors in .js files. */ - // "jsx": "preserve", /* Specify JSX code generation: 'preserve', 'react-native', 'react', 'react-jsx' or 'react-jsxdev'. */ - // "declaration": true, /* Generates corresponding '.d.ts' file. */ - // "declarationMap": true, /* Generates a sourcemap for each corresponding '.d.ts' file. */ - // "sourceMap": true, /* Generates corresponding '.map' file. */ - // "outFile": "./public/js/app.js", /* Concatenate and emit output to single file. */ - "outDir": "./dist/js/", /* Redirect output structure to the directory. */ - // "rootDir": "./", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */ - // "composite": true, /* Enable project compilation */ - // "tsBuildInfoFile": "./", /* Specify file to store incremental compilation information */ - // "removeComments": true, /* Do not emit comments to output. */ - // "noEmit": true, /* Do not emit outputs. */ - // "importHelpers": true, /* Import emit helpers from 'tslib'. */ - // "downlevelIteration": true, /* Provide full support for iterables in 'for-of', spread, and destructuring when targeting 'ES5' or 'ES3'. */ - // "isolatedModules": true, /* Transpile each file as a separate module (similar to 'ts.transpileModule'). */ - "moduleResolution": "node", - /* Strict Type-Checking Options */ - "strict": true, /* Enable all strict type-checking options. */ - // "noImplicitAny": true, /* Raise error on expressions and declarations with an implied 'any' type. */ - // "strictNullChecks": true, /* Enable strict null checks. */ - // "strictFunctionTypes": true, /* Enable strict checking of function types. */ - // "strictBindCallApply": true, /* Enable strict 'bind', 'call', and 'apply' methods on functions. */ - // "strictPropertyInitialization": true, /* Enable strict checking of property initialization in classes. */ - // "noImplicitThis": true, /* Raise error on 'this' expressions with an implied 'any' type. */ - // "alwaysStrict": true, /* Parse in strict mode and emit "use strict" for each source file. */ + /* Basic Options */ + // "incremental": true, /* Enable incremental compilation */ + "target": "ESNext" /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019', 'ES2020', 'ES2021', or 'ESNEXT'. */, + "module": "ESNext" /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', 'es2020', or 'ESNext'. */, + // "lib": ["ESNext"], /* Specify library files to be included in the compilation. */ + // "allowJs": true, /* Allow javascript files to be compiled. */ + // "checkJs": true, /* Report errors in .js files. */ + // "jsx": "preserve", /* Specify JSX code generation: 'preserve', 'react-native', 'react', 'react-jsx' or 'react-jsxdev'. */ + "declaration": true, /* Generates corresponding '.d.ts' file. */ + "declarationMap": true, /* Generates a sourcemap for each corresponding '.d.ts' file. */ + "sourceMap": true /* Generates corresponding '.map' file. */, + // "outFile": "./public/js/app.js", /* Concatenate and emit output to single file. */ + "outDir": "./dist/js/" /* Redirect output structure to the directory. */, + // "rootDir": "./", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */ + // "composite": true, /* Enable project compilation */ + // "tsBuildInfoFile": "./", /* Specify file to store incremental compilation information */ + "removeComments": true /* Do not emit comments to output. */, + // "noEmit": true, /* Do not emit outputs. */ + // "importHelpers": true, /* Import emit helpers from 'tslib'. */ + // "downlevelIteration": true, /* Provide full support for iterables in 'for-of', spread, and destructuring when targeting 'ES5' or 'ES3'. */ + // "isolatedModules": true, /* Transpile each file as a separate module (similar to 'ts.transpileModule'). */ + "moduleResolution": "node", + /* Strict Type-Checking Options */ + "strict": true /* Enable all strict type-checking options. */, + "noImplicitAny": true, /* Raise error on expressions and declarations with an implied 'any' type. */ + // "strictNullChecks": true, /* Enable strict null checks. */ + // "strictFunctionTypes": true, /* Enable strict checking of function types. */ + // "strictBindCallApply": true, /* Enable strict 'bind', 'call', and 'apply' methods on functions. */ + // "strictPropertyInitialization": true, /* Enable strict checking of property initialization in classes. */ + // "noImplicitThis": true, /* Raise error on 'this' expressions with an implied 'any' type. */ + // "alwaysStrict": true, /* Parse in strict mode and emit "use strict" for each source file. */ - /* Additional Checks */ - // "noUnusedLocals": true, /* Report errors on unused locals. */ - // "noUnusedParameters": true, /* Report errors on unused parameters. */ - // "noImplicitReturns": true, /* Report error when not all code paths in function return a value. */ - // "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */ - // "noUncheckedIndexedAccess": true, /* Include 'undefined' in index signature results */ - // "noImplicitOverride": true, /* Ensure overriding members in derived classes are marked with an 'override' modifier. */ - // "noPropertyAccessFromIndexSignature": true, /* Require undeclared properties from index signatures to use element accesses. */ + /* Additional Checks */ + // "noUnusedLocals": true, /* Report errors on unused locals. */ + // "noUnusedParameters": true, /* Report errors on unused parameters. */ + // "noImplicitReturns": true, /* Report error when not all code paths in function return a value. */ + // "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */ + // "noUncheckedIndexedAccess": true, /* Include 'undefined' in index signature results */ + // "noImplicitOverride": true, /* Ensure overriding members in derived classes are marked with an 'override' modifier. */ + // "noPropertyAccessFromIndexSignature": true, /* Require undeclared properties from index signatures to use element accesses. */ - /* Module Resolution Options */ - // "moduleResolution": "node", /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */ - // "baseUrl": "./", /* Base directory to resolve non-absolute module names. */ - // "paths": {}, /* A series of entries which re-map imports to lookup locations relative to the 'baseUrl'. */ - // "rootDirs": [], /* List of root folders whose combined content represents the structure of the project at runtime. */ - // "typeRoots": [], /* List of folders to include type definitions from. */ - // "types": [], /* Type declaration files to be included in compilation. */ - // "allowSyntheticDefaultImports": true, /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */ - "esModuleInterop": true, /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */ - // "preserveSymlinks": true, /* Do not resolve the real path of symlinks. */ - // "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */ + /* Module Resolution Options */ + // "moduleResolution": "node", /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */ + // "baseUrl": "./", /* Base directory to resolve non-absolute module names. */ + // "paths": {}, /* A series of entries which re-map imports to lookup locations relative to the 'baseUrl'. */ + // "rootDirs": [], /* List of root folders whose combined content represents the structure of the project at runtime. */ + // "typeRoots": [], /* List of folders to include type definitions from. */ + // "types": [], /* Type declaration files to be included in compilation. */ + // "allowSyntheticDefaultImports": true, /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */ + "esModuleInterop": true /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */, + // "preserveSymlinks": true, /* Do not resolve the real path of symlinks. */ + // "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */ - /* Source Map Options */ - // "sourceRoot": "", /* Specify the location where debugger should locate TypeScript files instead of source locations. */ - // "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */ - // "inlineSourceMap": true, /* Emit a single file with source maps instead of having a separate file. */ - // "inlineSources": true, /* Emit the source alongside the sourcemaps within a single file; requires '--inlineSourceMap' or '--sourceMap' to be set. */ + /* Source Map Options */ + // "sourceRoot": "", /* Specify the location where debugger should locate TypeScript files instead of source locations. */ + // "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */ + // "inlineSourceMap": true, /* Emit a single file with source maps instead of having a separate file. */ + // "inlineSources": true, /* Emit the source alongside the sourcemaps within a single file; requires '--inlineSourceMap' or '--sourceMap' to be set. */ - /* Experimental Options */ - // "experimentalDecorators": true, /* Enables experimental support for ES7 decorators. */ - // "emitDecoratorMetadata": true, /* Enables experimental support for emitting type metadata for decorators. */ + /* Experimental Options */ + // "experimentalDecorators": true, /* Enables experimental support for ES7 decorators. */ + // "emitDecoratorMetadata": true, /* Enables experimental support for emitting type metadata for decorators. */ - /* Advanced Options */ - "skipLibCheck": true, /* Skip type checking of declaration files. */ - "forceConsistentCasingInFileNames": true /* Disallow inconsistently-cased references to the same file. */ - }, - "include": [ - "./src/**/*.ts", - "./src/*.ts" - ], - "exclude": [ - "./tools/*.ts", - "./dist/*.ts", - "./dist/*.js" - ] + /* Advanced Options */ + "skipLibCheck": true /* Skip type checking of declaration files. */, + "forceConsistentCasingInFileNames": true /* Disallow inconsistently-cased references to the same file. */ + }, + "include": ["./src/**/*.ts", "./src/*.ts"], + "exclude": ["node_modules", "./tools/*.ts", "./dist/*.ts", "./dist/*.js"], + "types": ["node", "chrome"] } diff --git a/webpack.config.background.cjs b/webpack.config.background.cjs new file mode 100644 index 0000000..7102629 --- /dev/null +++ b/webpack.config.background.cjs @@ -0,0 +1,28 @@ +const path = require('path'); + +module.exports = { + entry: './src/background.ts', + mode: 'production', + devtool: 'source-map', + module: { + rules: [ + { + test: /\.tsx?$/, + use: 'ts-loader', + exclude: [ + "/node_modules/", + "/dist/", + "/src/app.ts", + "/src/settings.ts" + ], + }, + ], + }, + resolve: { + extensions: ['.tsx', '.ts'], + }, + output: { + filename: 'background.js', + path: path.resolve(__dirname, 'dist/js'), + }, +}; diff --git a/webpack.config.cjs b/webpack.config.cjs new file mode 100644 index 0000000..b7bf57e --- /dev/null +++ b/webpack.config.cjs @@ -0,0 +1,28 @@ +const path = require('path'); + +module.exports = { + entry: './src/app.ts', + mode: 'production', + devtool: 'source-map', + module: { + rules: [ + { + test: /\.tsx?$/, + use: 'ts-loader', + exclude: [ + "/node_modules/", + "/dist/", + "/src/background.ts", + "/src/settings.ts" + ], + }, + ], + }, + resolve: { + extensions: ['.tsx', '.ts'], + }, + output: { + filename: 'app.js', + path: path.resolve(__dirname, 'dist/js'), + }, +}; diff --git a/webpack.config.settings.cjs b/webpack.config.settings.cjs new file mode 100644 index 0000000..e8e1821 --- /dev/null +++ b/webpack.config.settings.cjs @@ -0,0 +1,28 @@ +const path = require('path'); + +module.exports = { + entry: './src/settings.ts', + mode: 'production', + devtool: 'source-map', + module: { + rules: [ + { + test: /\.tsx?$/, + use: 'ts-loader', + exclude: [ + "/node_modules/", + "/dist/", + "/src/background.ts", + "/src/app.ts" + ], + }, + ], + }, + resolve: { + extensions: ['.tsx', '.ts'], + }, + output: { + filename: 'settings.js', + path: path.resolve(__dirname, 'dist/js'), + }, +}; From 43b2d8c82b409a77386faf68843b231d8b9b68a7 Mon Sep 17 00:00:00 2001 From: Jonas Pfalzgraf Date: Tue, 24 Jan 2023 01:03:04 +0100 Subject: [PATCH 2/3] style update --- package.json | 5 +- src/sass/_button.sass | 226 ------------------------------------------ src/sass/_input.sass | 36 ------- src/sass/_root.sass | 6 ++ src/sass/app.sass | 3 +- src/settings.ts | 2 +- 6 files changed, 11 insertions(+), 267 deletions(-) delete mode 100644 src/sass/_button.sass delete mode 100644 src/sass/_input.sass diff --git a/package.json b/package.json index 3bd50a2..a383aac 100644 --- a/package.json +++ b/package.json @@ -18,8 +18,8 @@ "@types/node": "^18.11.18", "@webcomponents/webcomponentsjs": "^2.7.0", "sass": "^1.39.0", - "typescript": "^4.2.4", "ts-loader": "^9.4.2", + "typescript": "^4.2.4", "webpack": "^5.75.0", "webpack-cli": "^5.0.1" }, @@ -45,6 +45,7 @@ "url": "https://github.com/JosunLP/BrowserExtensionTemplate/issues" }, "dependencies": { - "@webcomponents/custom-elements": "^1.5.1" + "@webcomponents/custom-elements": "^1.5.1", + "bootstrap": "^5.2.3" } } \ No newline at end of file diff --git a/src/sass/_button.sass b/src/sass/_button.sass deleted file mode 100644 index de19aab..0000000 --- a/src/sass/_button.sass +++ /dev/null @@ -1,226 +0,0 @@ -@import 'mixin' - -.btn-neutral - color: #fff - background-color: #000 - border-color: #000 - @include partialButton - -.btn-neutral:hover - color: #000 - background-color: #fff - border-color: #fff - -.btn-neutral:focus, .btn-neutral.focus - box-shadow: 0 0 0 0.2rem rgba(0, 123, 255, 0.5) - -.btn-neutral.disabled, .btn-neutral:disabled - color: #fff - background-color: #000 - border-color: #000 - -.btn-neutral:not(:disabled):not(.disabled):active, .btn-neutral:not(:disabled):not(.disabled).active, -.show > .btn-neutral.dropdown-toggle - color: #000 - background-color: #fff - border-color: #fff - -.btn-primary - color: #fff - background-color: #007bff - border-color: #007bff - @include partialButton - -.btn-primary:hover - color: #fff - background-color: #0069d9 - border-color: #0062cc - -.btn-primary:focus, .btn-primary.focus - box-shadow: 0 0 0 0.2rem rgba(0, 123, 255, 0.5) - -.btn-primary.disabled, .btn-primary:disabled - color: #fff - background-color: #007bff - border-color: #007bff - -.btn-primary:not(:disabled):not(.disabled):active, .btn-primary:not(:disabled):not(.disabled).active, -.show > .btn-primary.dropdown-toggle - color: #fff - background-color: #0062cc - border-color: #005cbf - -.btn-secondary - color: #fff - background-color: #6c757d - border-color: #6c757d - @include partialButton - -.btn-secondary:hover - color: #fff - background-color: #5a6268 - border-color: #545b62 - -.btn-secondary:focus, .btn-secondary.focus - box-shadow: 0 0 0 0.2rem rgba(130, 138, 145, 0.5) - -.btn-secondary.disabled, .btn-secondary:disabled - color: #fff - background-color: #6c757d - border-color: #6c757d - -.btn-secondary:not(:disabled):not(.disabled):active, .btn-secondary:not(:disabled):not(.disabled).active, -.show > .btn-secondary.dropdown-toggle - color: #fff - background-color: #545b62 - border-color: #4e555b - -.btn-success - color: #fff - background-color: #28a745 - border-color: #28a745 - @include partialButton - -.btn-success:hover - color: #fff - background-color: #218838 - border-color: #1e7e34 - -.btn-success:focus, .btn-success.focus - box-shadow: 0 0 0 0.2rem rgba(40, 167, 69, 0.5) - -.btn-success.disabled, .btn-success:disabled - color: #fff - background-color: #28a745 - border-color: #28a745 - -.btn-success:not(:disabled):not(.disabled):active, .btn-success:not(:disabled):not(.disabled).active, -.show > .btn-success.dropdown-toggle - color: #fff - background-color: #1e7e34 - border-color: #1c7430 - -.btn-info - color: #fff - background-color: #17a2b8 - border-color: #17a2b8 - @include partialButton - -.btn-info:hover - color: #fff - background-color: #138496 - border-color: #117a8b - -.btn-info:focus, .btn-info.focus - box-shadow: 0 0 0 0.2rem rgba(23, 162, 184, 0.5) - -.btn-info.disabled, .btn-info:disabled - color: #fff - background-color: #17a2b8 - border-color: #17a2b8 - -.btn-info:not(:disabled):not(.disabled):active, .btn-info:not(:disabled):not(.disabled).active, -.show > .btn-info.dropdown-toggle - color: #fff - background-color: #117a8b - border-color: #10707f - -.btn-warning - color: #212529 - background-color: #ffc107 - border-color: #ffc107 - @include partialButton - -.btn-warning:hover - color: #212529 - background-color: #e0a800 - border-color: #d39e00 - -.btn-warning:focus, .btn-warning.focus - box-shadow: 0 0 0 0.2rem rgba(255, 193, 7, 0.5) - -.btn-warning.disabled, .btn-warning:disabled - color: #212529 - background-color: #ffc107 - border-color: #ffc107 - -.btn-warning:not(:disabled):not(.disabled):active, .btn-warning:not(:disabled):not(.disabled).active, -.show > .btn-warning.dropdown-toggle - color: #212529 - background-color: #d39e00 - border-color: #c69500 - -.btn-danger - color: #fff - background-color: #dc3545 - border-color: #dc3545 - @include partialButton - -.btn-danger:hover - color: #fff - background-color: #c82333 - border-color: #bd2130 - -.btn-danger:focus, .btn-danger.focus - box-shadow: 0 0 0 0.2rem rgba(220, 53, 69, 0.5) - -.btn-danger.disabled, .btn-danger:disabled - color: #fff - background-color: #dc3545 - border-color: #dc3545 - -.btn-danger:not(:disabled):not(.disabled):active, .btn-danger:not(:disabled):not(.disabled).active, -.show > .btn-danger.dropdown-toggle - color: #fff - background-color: #bd2130 - border-color: #b21f2d - -.btn-light - color: #212529 - background-color: #f8f9fa - border-color: #f8f9fa - @include partialButton - -.btn-light:hover - color: #212529 - background-color: #e2e6ea - border-color: #dae0e5 - -.btn-light:focus, .btn-light.focus - box-shadow: 0 0 0 0.2rem rgba(248, 249, 250, 0.5) - -.btn-light.disabled, .btn-light:disabled - color: #212529 - background-color: #f8f9fa - border-color: #f8f9fa - -.btn-light:not(:disabled):not(.disabled):active, .btn-light:not(:disabled):not(.disabled).active, -.show > .btn-light.dropdown-toggle - color: #212529 - background-color: #dae0e5 - border-color: #d3d9df - -.btn-dark - color: #fff - background-color: #343a40 - border-color: #343a40 - @include partialButton - -.btn-dark:hover - color: #fff - background-color: #23272b - border-color: #1d2124 - -.btn-dark:focus, .btn-dark.focus - box-shadow: 0 0 0 0.2rem rgba(52, 58, 64, 0.5) - -.btn-dark.disabled, .btn-dark:disabled - color: #fff - background-color: #343a40 - border-color: #343a40 - -.btn-dark:not(:disabled):not(.disabled):active, .btn-dark:not(:disabled):not(.disabled).active, -.show > .btn-dark.dropdown-toggle - color: #fff - background-color: #1d2124 - border-color: #171a1d diff --git a/src/sass/_input.sass b/src/sass/_input.sass deleted file mode 100644 index 4e4c4e8..0000000 --- a/src/sass/_input.sass +++ /dev/null @@ -1,36 +0,0 @@ -@import 'root' - -.text-input - width: 80% - height: 2rem - border: none - border-radius: 0.5rem - padding: 0.5rem - margin-bottom: 0.5rem - font-size: 1rem - font-family: 'Roboto', sans-serif - color: $seccondary-color - background-color: $background-color-content - &:focus - outline: none - background-color: $background-color-content-focus - color: $seccondary-color - box-shadow: 0px 0px 30px silver - &:disabled - background-color: $background-color-content-disabled - color: $seccondary-color-disabled - box-shadow: none - &:hover - background-color: $background-color-content-hover - color: $seccondary-color-hover - box-shadow: 0px 0px 30px silver - &:active - background-color: $background-color-content-active - color: $seccondary-color-active - box-shadow: 0px 0px 30px silver - -label - font-size: 1rem - font-family: 'Roboto', sans-serif - color: $main-font-color - margin-bottom: 0.5rem diff --git a/src/sass/_root.sass b/src/sass/_root.sass index b380612..3a50f8d 100644 --- a/src/sass/_root.sass +++ b/src/sass/_root.sass @@ -5,6 +5,12 @@ $main-font-color-focus: lightgrey $main-font-color-disabled: lightgrey $main-font-color-active: lightgrey $main-uschrift-font: 'Ubuntu', Arial +$primary-color: #007bff +$primary-color-hover: #0069d9 +$primary-color-focus: #0062cc +$primary-color-disabled: #0069d9 +$primary-color-active: #0062cc +$background-color-content-shadow: #0069d9 $seccond-color: #6c757d $seccondary-color: darkgrey $seccondary-color-hover: black diff --git a/src/sass/app.sass b/src/sass/app.sass index 4c0cfae..f953809 100644 --- a/src/sass/app.sass +++ b/src/sass/app.sass @@ -1,8 +1,7 @@ @import 'root' @import 'mixin' @import 'content' -@import 'button' -@import 'input' +@import "../../node_modules/bootstrap/scss/bootstrap" body height: 30rem diff --git a/src/settings.ts b/src/settings.ts index 60538bd..24d6bb8 100644 --- a/src/settings.ts +++ b/src/settings.ts @@ -14,8 +14,8 @@ class Settings { const saveButton = new BasicButton('success', 'Save', 'saveSettings').render(); settings.innerHTML = `
- +
`; settings.innerHTML += saveButton; From 741de12320d87e71710d654e17a90b5df5ebfae1 Mon Sep 17 00:00:00 2001 From: Jonas Pfalzgraf Date: Fri, 4 Aug 2023 11:05:20 +0200 Subject: [PATCH 3/3] :children_crossing: Updating and optimizing --- package.json | 8 ++++---- tools/clean.ts | 3 ++- tools/deploy.ts | 12 +++++++----- tools/syncConfig.ts | 15 ++++++++------- tools/v2.ts | 5 +++-- ...background.cjs => webpack.config.background.ts | 0 ...fig.settings.cjs => webpack.config.settings.ts | 0 webpack.config.cjs => webpack.config.ts | 0 8 files changed, 24 insertions(+), 19 deletions(-) rename webpack.config.background.cjs => webpack.config.background.ts (100%) rename webpack.config.settings.cjs => webpack.config.settings.ts (100%) rename webpack.config.cjs => webpack.config.ts (100%) diff --git a/package.json b/package.json index a383aac..f50e507 100644 --- a/package.json +++ b/package.json @@ -2,11 +2,10 @@ "name": "browser_extension_template", "version": "0.0.1", "private": true, - "type": "module", "scripts": { - "deploy-v3": "npm run build-tooling && node ./tools/deploy.js && npm run sync && npm run build-js && npm run build-css && node ./tools/clean.js", - "deploy-v2": "npm run deploy-v3 && node ./tools/v2.js", - "build-js": "webpack --config ./webpack.config.cjs && webpack --config ./webpack.config.settings.cjs && webpack --config ./webpack.config.background.cjs", + "deploy-v3": "npx rimraf ./dist/ && npm run build-tooling && node ./tools/deploy.js && npm run sync && npm run build-js && npm run build-css && node ./tools/clean.js", + "deploy-v2": " npm run deploy-v3 && node ./tools/v2.js", + "build-js": "webpack --config ./webpack.config.ts && webpack --config ./webpack.config.settings.ts && webpack --config ./webpack.config.background.ts", "build-css": "sass ./src/sass/:./dist/css/", "build-tooling": "tsc --project ./tooling.tsconfig.json", "watch-ts": "tsc -w -p tsconfig.json", @@ -19,6 +18,7 @@ "@webcomponents/webcomponentsjs": "^2.7.0", "sass": "^1.39.0", "ts-loader": "^9.4.2", + "ts-node": "^10.9.1", "typescript": "^4.2.4", "webpack": "^5.75.0", "webpack-cli": "^5.0.1" diff --git a/tools/clean.ts b/tools/clean.ts index caba573..2ed412e 100644 --- a/tools/clean.ts +++ b/tools/clean.ts @@ -1,4 +1,5 @@ -import * as fs from "fs"; +// @ts-ignore +const fs = require("fs"); function removeExport(file: string) { let content = fs.readFileSync(file, "utf8"); diff --git a/tools/deploy.ts b/tools/deploy.ts index a12bf54..7308509 100644 --- a/tools/deploy.ts +++ b/tools/deploy.ts @@ -1,6 +1,8 @@ -import * as fs from 'fs'; -import * as path from 'path'; -const appConfig = JSON.parse(fs.readFileSync('./app.config.json', 'utf8')); +const path = require('path'); +// @ts-ignore +const fs = require('fs'); + +const appConfigJson = JSON.parse(fs.readFileSync('./app.config.json', 'utf8')); const DEPLOY_ENTRY = "./public/"; const DEPLOY_TARGET = "./dist/"; @@ -37,7 +39,7 @@ function findHtmlFilesRecursive(source: string): string[] { function replaceKeywordsInHtmlFile(file: string) { let content = fs.readFileSync(file, 'utf8'); - const pairs = appConfig.htmlTemplatePairs; + const pairs = appConfigJson.htmlTemplatePairs; pairs.forEach(function (pair: object) { // @ts-ignore content = content.replaceAll(pair.key, pair.value); @@ -81,4 +83,4 @@ mkdirSync(DEPLOY_TARGET); copyFiles(DEPLOY_ENTRY, DEPLOY_TARGET); buildHtmlFiles(DEPLOY_ENTRY); -console.log("Deployed to " + DEPLOY_TARGET); \ No newline at end of file +console.log("Deployed to " + DEPLOY_TARGET); diff --git a/tools/syncConfig.ts b/tools/syncConfig.ts index 22b800c..a9eeaa5 100644 --- a/tools/syncConfig.ts +++ b/tools/syncConfig.ts @@ -1,8 +1,9 @@ -import * as fs from 'fs'; +// @ts-ignore +const fs = require('fs'); const appConfig = JSON.parse(fs.readFileSync('./app.config.json', 'utf8')); const pkg = JSON.parse(fs.readFileSync('./package.json', 'utf8')); -const manifest = JSON.parse(fs.readFileSync('./public/manifest.json', 'utf8')); +const manifestJson = JSON.parse(fs.readFileSync('./public/manifest.json', 'utf8')); pkg.version = appConfig.AppData.version; pkg.name = appConfig.AppData.id; @@ -13,10 +14,10 @@ pkg.license = appConfig.AppData.license; pkg.repository = appConfig.AppData.repository; pkg.bugs = appConfig.AppData.bugs; -manifest.version = appConfig.AppData.version; -manifest.name = appConfig.AppData.name; -manifest.description = appConfig.AppData.description; -manifest.homepage_url = appConfig.AppData.homepage; +manifestJson.version = appConfig.AppData.version; +manifestJson.name = appConfig.AppData.name; +manifestJson.description = appConfig.AppData.description; +manifestJson.homepage_url = appConfig.AppData.homepage; fs.writeFileSync('./package.json', JSON.stringify(pkg, null, 2)); -fs.writeFileSync('./public/manifest.json', JSON.stringify(manifest, null, 2)); \ No newline at end of file +fs.writeFileSync('./public/manifest.json', JSON.stringify(manifestJson, null, 2)); diff --git a/tools/v2.ts b/tools/v2.ts index dd42ddb..d958bbe 100644 --- a/tools/v2.ts +++ b/tools/v2.ts @@ -1,4 +1,5 @@ -import * as fs from 'fs'; +// @ts-ignore +const fs = require('fs'); const manifest = JSON.parse(fs.readFileSync('./dist/manifest.json', 'utf8')); @@ -42,4 +43,4 @@ if (manifest.action) { } delete manifest.action -fs.writeFileSync('./dist/manifest.json', JSON.stringify(manifest, null, 2)); \ No newline at end of file +fs.writeFileSync('./dist/manifest.json', JSON.stringify(manifest, null, 2)); diff --git a/webpack.config.background.cjs b/webpack.config.background.ts similarity index 100% rename from webpack.config.background.cjs rename to webpack.config.background.ts diff --git a/webpack.config.settings.cjs b/webpack.config.settings.ts similarity index 100% rename from webpack.config.settings.cjs rename to webpack.config.settings.ts diff --git a/webpack.config.cjs b/webpack.config.ts similarity index 100% rename from webpack.config.cjs rename to webpack.config.ts