OSDN Git Service

chore: do not build the crx
authorj <coffce404@gmail.com>
Fri, 26 Feb 2021 06:14:07 +0000 (14:14 +0800)
committerj <coffce404@gmail.com>
Fri, 26 Feb 2021 06:14:07 +0000 (14:14 +0800)
build/build.js
build/webpack.prod.conf.js
src/manifest.js [deleted file]
src/manifest.json [new file with mode: 0644]

index 3800bee..10bdc9a 100644 (file)
@@ -1,40 +1,52 @@
-const chalk = require('chalk')
-const webpack = require('webpack')
-const merge = require('webpack-merge')
-const Crx = require("crx-webpack-plugin")
-const generatePem = require('./generate-pem')
-const prodConf = require('./webpack.prod.conf')
-const crxConf = require('./crx-conf')
+const fs = require("fs");
+const chalk = require("chalk");
+const webpack = require("webpack");
+const Crx = require("crx");
+const merge = require("webpack-merge");
+// const Crx = require("crx-webpack-plugin")
+const generatePem = require("./generate-pem");
+const prodConf = require("./webpack.prod.conf");
+const crxConf = require("./crx-conf");
+const { resolve } = require("./util");
 
-generatePem(crxConf.keyPath).then(info => {
-  console.log(chalk.green(info))
-  const conf = merge(prodConf, {
-    plugins: [
-      new Crx({
-        keyFile: crxConf.keyPath,
-        contentPath: crxConf.contentPath,
-        outputPath: crxConf.outputPath,
-        name: crxConf.name
-      })
-    ]
-  })
-  webpack(conf, (err, stats) => {
-    if (err) throw err
-    process.stdout.write(stats.toString({
+webpack(prodConf, (err, stats) => {
+  if (err) throw err;
+  process.stdout.write(
+    stats.toString({
       colors: true,
       modules: false,
       children: false, // If you are using ts-loader, setting this to true will make TypeScript errors show up during build.
       chunks: false,
       chunkModules: false
-    }) + '\n\n')
+    }) + "\n\n"
+  );
 
-    if (stats.hasErrors()) {
-      console.log(chalk.red('  Build failed with errors.\n'))
-      process.exit(1)
-    }
+  if (stats.hasErrors()) {
+    console.log(chalk.red("  Build failed with errors.\n"));
+    process.exit(1);
+  }
 
-    console.log(chalk.cyan('  Build complete.\n'))
-  })
-}).catch(err => {
-  console.log(chalk.red(err))
-})
+  console.log(chalk.cyan(" Crx building. \n"));
+
+  // const crx = new Crx({
+  //   codebase: "http://localhost:8000/chrome-ext.crx",
+  //   privateKey: fs.readFileSync(crxConf.keyPath)
+  // });
+  // crx
+  //   .load(crxConf.contentPath)
+  //   .then(crx => crx.pack())
+  //   .then(crxBuffer => {
+  //     const updateXML = crx.generateUpdateXML();
+  //     return Promise.all([
+  //       fs.promises.writeFile(resolve("./dist/updates.xml"), updateXML),
+  //       fs.promises.writeFile(resolve("./dist/byone.crx"), crxBuffer)
+  //     ]);
+  //   })
+  //   .then(() => {
+  //     console.log(chalk.cyan(" Crx Build complete.\n"));
+  //   })
+  //   .catch(err => {
+  //     console.log(chalk.red(" Crx build failed.\n"));
+  //     console.log(err);
+  //   });
+});
index a035e72..d14b81b 100644 (file)
@@ -15,6 +15,11 @@ module.exports = merge(baseConf, {
     new CleanWebpackPlugin(["dist/*.*"]),
     new webpack.LoaderOptionsPlugin({
       minimize: true
-    })
+    }),
+    new CopyWebpackPlugin([
+      {
+        from: resolve('./src/manifest.json')
+      }
+    ]),
   ]
 });
diff --git a/src/manifest.js b/src/manifest.js
deleted file mode 100644 (file)
index c70dc6b..0000000
+++ /dev/null
@@ -1,38 +0,0 @@
-module.exports = {
-  manifest_version: 2,
-  name: 'Byone',
-  description: 'Bytom Wallet Chrome extension.',
-  version: '3.0.8',
-  author: 'Bytom frontend, zhitinglin',
-  web_accessible_resources: ['js/inject.js'],
-  browser_action: {
-    default_popup: 'pages/popup.html',
-    default_icon: 'icons/logo.png'
-  },
-  icons: {
-    '16': 'icons/logo.png',
-    '48': 'icons/logo.png',
-    '128': 'icons/logo.png'
-  },
-  permissions: [
-    '*://*/',
-    'storage',
-    "unlimitedStorage",
-    'contextMenus',
-    'clipboardWrite',
-    'clipboardRead',
-    'background'
-  ],
-  content_security_policy: "script-src 'self'  'unsafe-eval' https://www.google-analytics.com/analytics.js; object-src 'self'",
-  content_scripts: [
-    {
-      js: ['js/content.js'],
-      run_at: 'document_end',
-      matches: ['<all_urls>'],
-      all_frames: true
-    }
-  ],
-  background: {
-    scripts: ['js/background.js']
-  }
-}
diff --git a/src/manifest.json b/src/manifest.json
new file mode 100644 (file)
index 0000000..b1f504b
--- /dev/null
@@ -0,0 +1,38 @@
+{
+  "manifest_version": 2,
+  "name": "Byone",
+  "description": "Bytom Wallet Chrome extension.",
+  "version": "3.0.9",
+  "author": "Bytom frontend, zhitinglin",
+  "web_accessible_resources": ["js/inject.js"],
+  "browser_action": {
+    "default_popup": "pages/popup.html",
+    "default_icon": "icons/logo.png"
+  },
+  "icons": {
+    "16": "icons/logo.png",
+    "48": "icons/logo.png",
+    "128": "icons/logo.png"
+  },
+  "permissions": [
+    "*://*/",
+    "storage",
+    "unlimitedStorage",
+    "contextMenus",
+    "clipboardWrite",
+    "clipboardRead",
+    "background"
+  ],
+  "content_security_policy": "script-src 'self'  'unsafe-eval' https://www.google-analytics.com/analytics.js; object-src 'self'",
+  "content_scripts": [
+    {
+      "js": ["js/content.js"],
+      "run_at": "document_end",
+      "matches": ["<all_urls>"],
+      "all_frames": true
+    }
+  ],
+  "background": {
+    "scripts": ["js/background.js"]
+  }
+}