Ver código fonte

ref: update npm commands for build

Sv443 1 ano atrás
pai
commit
589271e46e
3 arquivos alterados com 14 adições e 4 exclusões
  1. 4 2
      package.json
  2. 5 0
      src/types.d.ts
  3. 5 2
      webpack.config.js

+ 4 - 2
package.json

@@ -10,9 +10,11 @@
   "scripts": {
     "test": "npm run node-ts -- ./test.ts",
     "build": "webpack",
+    "build-prod": "webpack --env mode=production",
+    "build-dev": "webpack --env mode=development",
     "post-build": "npm run node-ts -- ./src/tools/post-build.ts",
     "serve": "npm run node-ts -- ./src/tools/serve.ts",
-    "watch": "concurrently \"nodemon --exec npm run build\" \"npm run serve\"",
+    "watch": "concurrently \"nodemon --exec npm run build-dev\" \"npm run serve\"",
     "lint": "tsc --noEmit && eslint .",
     "node-ts": "node --no-warnings=ExperimentalWarning --enable-source-maps --loader ts-node/esm"
   },
@@ -71,4 +73,4 @@
       "dev/*"
     ]
   }
-}
+}

+ 5 - 0
src/types.d.ts

@@ -1,3 +1,6 @@
+/** Env object passed to webpack.config.js */
+export type WebpackEnv = Partial<Record<"mode", "production" | "development">> & Record<"WEBPACK_BUNDLE" | "WEBPACK_BUILD", boolean>;
+
 /** 0 = Debug, 1 = Info */
 export type LogLevel = 0 | 1;
 
@@ -38,4 +41,6 @@ export interface FeatureConfig {
   //#SECTION lyrics
   /** Add a button to the media controls to open the current song's lyrics on genius.com in a new tab */
   geniusLyrics: boolean;
+  // /** Add a button to each song in the queue to allow for quickly pre-opening lyrics pages of upcoming songs */
+  // geniusLyricsInQueue: boolean;
 }

+ 5 - 2
webpack.config.js

@@ -11,7 +11,8 @@ dotenv.config();
 const mode = ["development", "production"].includes(process.env.NODE_ENV) ? process.env.NODE_ENV : "development";
 const outFileSuffix = process.env.OUTFILE_SUFFIX ?? "";
 
-export default {
+/** @param {import("./src/types").WebpackEnv} env */
+const getConfig = (env) => ({
   entry: "./src/BetterYTM.user.ts",
   output: {
     filename: `BetterYTM${outFileSuffix}.user.js`,
@@ -80,4 +81,6 @@ export default {
     },
   ],
   devtool: "source-map",
-};
+});
+
+export default getConfig;