From 6c2845f8e5929d1b8f1925d81a78012c9296b223 Mon Sep 17 00:00:00 2001 From: gxz Date: Tue, 17 Oct 2023 18:50:51 +0800 Subject: [PATCH] chore: add package.json --- package.json | 3 ++- scripts/build-finished.ts | 17 +++++++++++++++++ webpack.config.js | 2 +- 3 files changed, 20 insertions(+), 2 deletions(-) create mode 100644 scripts/build-finished.ts diff --git a/package.json b/package.json index f57e02f..4464f3d 100644 --- a/package.json +++ b/package.json @@ -13,7 +13,8 @@ "main": "src/index.ts", "scripts": { "prepare": "husky install", - "build": "NODE_ENV=production webpack", + "build": "NODE_ENV=production webpack && pnpm create-package", + "create-package": "node scripts/build-finished.ts", "watch": "webpack --watch --mode=development", "test": "vitest --coverage", "test:watch": "vitest --ui", diff --git a/scripts/build-finished.ts b/scripts/build-finished.ts new file mode 100644 index 0000000..8f102b1 --- /dev/null +++ b/scripts/build-finished.ts @@ -0,0 +1,17 @@ +const fs = require("fs"); +const path = require("path"); + +const pkg = require("../package.json"); + +const distDir = "dist"; + +const packageData = { + name: "agora-rtc-sdk-ng-fake", + version: "1.0.0", + description: "Fake Agora Web RTC for testing", + main: `${pkg.name}_${pkg.version}.js`, +}; + +const packagePath = path.join(distDir, "package.json"); + +fs.writeFileSync(packagePath, JSON.stringify(packageData, null, 2)); diff --git a/webpack.config.js b/webpack.config.js index 12f0833..ad15a6d 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -17,7 +17,7 @@ let config = { type: "umd", umdNamedDefine: true, }, - filename: `iris-web-rtc-fake_${pkg.version}.js`, + filename: `${pkg.name}_${pkg.version}.js`, globalObject: "this", environment: { arrowFunction: false,