From 0e725569e5c93f0e54b27986ad359d396b5a301b Mon Sep 17 00:00:00 2001 From: Nelson Chan Date: Thu, 29 Jun 2023 06:50:55 +0800 Subject: [PATCH 1/9] Feat: Add placeholders for badge generator Chore: Save as dev dep. --- config/vite.config.js | 5 +++ package-lock.json | 29 +++++++++++++++++ package.json | 1 + server/config.js | 3 +- src/components/BadgeGeneratorDialog.vue | 42 ++++++++++++++----------- 5 files changed, 61 insertions(+), 19 deletions(-) diff --git a/config/vite.config.js b/config/vite.config.js index 6e9ebbde..f9ca0651 100644 --- a/config/vite.config.js +++ b/config/vite.config.js @@ -3,6 +3,7 @@ import vue from "@vitejs/plugin-vue"; import { defineConfig } from "vite"; import visualizer from "rollup-plugin-visualizer"; import viteCompression from "vite-plugin-compression"; +import commonjs from "vite-plugin-commonjs"; const postCssScss = require("postcss-scss"); const postcssRTLCSS = require("postcss-rtlcss"); @@ -18,6 +19,7 @@ export default defineConfig({ "FRONTEND_VERSION": JSON.stringify(process.env.npm_package_version), }, plugins: [ + commonjs(), vue(), legacy({ targets: [ "since 2015" ], @@ -42,6 +44,9 @@ export default defineConfig({ } }, build: { + commonjsOptions: { + include: [ /.js$/ ], + }, rollupOptions: { output: { manualChunks(id, { getModuleInfo, getModuleIds }) { diff --git a/package-lock.json b/package-lock.json index f3bc2fae..da1eb590 100644 --- a/package-lock.json +++ b/package-lock.json @@ -114,6 +114,7 @@ "typescript": "~4.4.4", "v-pagination-3": "~0.1.7", "vite": "~3.2.7", + "vite-plugin-commonjs": "^0.8.0", "vite-plugin-compression": "^0.5.1", "vue": "~3.2.47", "vue-chartjs": "~5.2.0", @@ -8528,6 +8529,12 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/es-module-lexer": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/es-module-lexer/-/es-module-lexer-1.3.0.tgz", + "integrity": "sha512-vZK7T0N2CBmBOixhmjdqx2gWVbFZ4DXZ/NyRMZVlJXPa7CyFS+/a4QQsDGDQy9ZfEzxFuNEsMLeQJnKP2p5/JA==", + "dev": true + }, "node_modules/es-set-tostringtag": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/es-set-tostringtag/-/es-set-tostringtag-2.0.1.tgz", @@ -18687,6 +18694,17 @@ } } }, + "node_modules/vite-plugin-commonjs": { + "version": "0.8.0", + "resolved": "https://registry.npmjs.org/vite-plugin-commonjs/-/vite-plugin-commonjs-0.8.0.tgz", + "integrity": "sha512-55v9Gjp2MpZ0vaDLNRbztI9hiTXaw/aQ8QnqNhGz4lwH0nnYHGeEOjzRS3kTrRljB8m6GQUrgi59UWu6N9KjVQ==", + "dev": true, + "dependencies": { + "acorn": "^8.8.2", + "fast-glob": "^3.2.12", + "vite-plugin-dynamic-import": "^1.4.0" + } + }, "node_modules/vite-plugin-compression": { "version": "0.5.1", "resolved": "https://registry.npmjs.org/vite-plugin-compression/-/vite-plugin-compression-0.5.1.tgz", @@ -18785,6 +18803,17 @@ "node": ">=8" } }, + "node_modules/vite-plugin-dynamic-import": { + "version": "1.4.1", + "resolved": "https://registry.npmjs.org/vite-plugin-dynamic-import/-/vite-plugin-dynamic-import-1.4.1.tgz", + "integrity": "sha512-DdAVMCXFK5/IyHLs/l3vciTVCQa5u+C+6mhLOtx82l7MDAPcBAsk36aPd1SLgqm1bCkc7kAC4S5Nqi0dyrlMnQ==", + "dev": true, + "dependencies": { + "acorn": "^8.8.2", + "es-module-lexer": "^1.2.1", + "fast-glob": "^3.2.12" + } + }, "node_modules/vue": { "version": "3.2.47", "resolved": "https://registry.npmjs.org/vue/-/vue-3.2.47.tgz", diff --git a/package.json b/package.json index 1ca874af..6113e8b9 100644 --- a/package.json +++ b/package.json @@ -173,6 +173,7 @@ "typescript": "~4.4.4", "v-pagination-3": "~0.1.7", "vite": "~3.2.7", + "vite-plugin-commonjs": "^0.8.0", "vite-plugin-compression": "^0.5.1", "vue": "~3.2.47", "vue-chartjs": "~5.2.0", diff --git a/server/config.js b/server/config.js index 43a40f67..77f9e74b 100644 --- a/server/config.js +++ b/server/config.js @@ -1,4 +1,5 @@ -const args = require("args-parser")(process.argv); +// Interop with browser +const args = (typeof process !== "undefined") ? require("args-parser")(process.argv) : {}; const demoMode = args["demo"] || false; const badgeConstants = { diff --git a/src/components/BadgeGeneratorDialog.vue b/src/components/BadgeGeneratorDialog.vue index 9e073e39..d9de7a85 100644 --- a/src/components/BadgeGeneratorDialog.vue +++ b/src/components/BadgeGeneratorDialog.vue @@ -22,78 +22,78 @@
- - + +
- +
- +
- +
- +
- +
- +
- +
- +
- +
- +
- +
- +
- +
- +
@@ -109,7 +109,11 @@
- + +
+ +
+ Badge Preview
@@ -131,6 +135,7 @@